hardware/intel/libva
Révision | c3ab994edf2a20e9e8c96dce8883c1df99b88849 (tree) |
---|---|
l'heure | 2011-12-14 09:27:03 |
Auteur | Xiang, Haihao <haihao.xiang@inte...> |
Commiter | Xiang, Haihao |
Array bound check
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
@@ -183,7 +183,7 @@ int vaMaxNumSurfaceTargetsEGL( | ||
183 | 183 | if (va_egl) |
184 | 184 | return va_egl->max_egl_surface_targets; |
185 | 185 | else |
186 | - return 2; | |
186 | + return IMPL_MAX_EGL_SURFACE_TARGETS; | |
187 | 187 | } |
188 | 188 | |
189 | 189 | int vaMaxNumSurfaceAttributesEGL( |
@@ -200,7 +200,7 @@ int vaMaxNumSurfaceAttributesEGL( | ||
200 | 200 | if (va_egl) |
201 | 201 | return va_egl->max_egl_surface_attributes; |
202 | 202 | else |
203 | - return 2; | |
203 | + return IMPL_MAX_EGL_SURFACE_ATTRIBUTES; | |
204 | 204 | } |
205 | 205 | |
206 | 206 | VAStatus vaQuerySurfaceTargetsEGL( |
@@ -282,8 +282,10 @@ vaQuerySurfaceTargetsEGL_impl_libva(VADisplay dpy, | ||
282 | 282 | { |
283 | 283 | int i = 0; |
284 | 284 | |
285 | + /* FIXME: support other targets ??? */ | |
285 | 286 | target_list[i++] = EGL_NATIVE_PIXMAP_KHR; |
286 | 287 | *num_targets = i; |
288 | + assert(i <= IMPL_MAX_EGL_SURFACE_TARGETS); | |
287 | 289 | |
288 | 290 | return VA_STATUS_SUCCESS; |
289 | 291 | } |
@@ -297,6 +299,10 @@ vaCreateSurfaceEGL_impl_libva(VADisplay dpy, | ||
297 | 299 | { |
298 | 300 | VASurfaceImplEGLP pSurfaceImplEGL = NULL; |
299 | 301 | |
302 | + /* So far only support for EGL_NATIVE_PIXMAP_KHR */ | |
303 | + if (target != 0 && target != EGL_NATIVE_PIXMAP_KHR) | |
304 | + return VA_STATUS_ERROR_INVALID_PARAMETER; | |
305 | + | |
300 | 306 | pSurfaceImplEGL = calloc(1, sizeof(*pSurfaceImplEGL)); |
301 | 307 | |
302 | 308 | if (!pSurfaceImplEGL) { |
@@ -400,18 +406,23 @@ vaGetSurfaceInfoEGL_impl_libva(VADisplay dpy, | ||
400 | 406 | if (pSurfaceImplEGL->surface == VA_INVALID_SURFACE) |
401 | 407 | return VA_STATUS_ERROR_INVALID_SURFACE; |
402 | 408 | |
409 | + if (*num_attribs < IMPL_MAX_EGL_SURFACE_ATTRIBUTES) | |
410 | + return VA_STATUS_ERROR_INVALID_PARAMETER; | |
411 | + | |
403 | 412 | *target = pSurfaceImplEGL->target; |
404 | 413 | *buffer = pSurfaceImplEGL->buffer; |
405 | 414 | |
406 | 415 | if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) { |
407 | 416 | attrib_list[i++] = EGL_IMAGE_PRESERVED_KHR; |
408 | - attrib_list[i++] = EGL_TRUE; | |
417 | + attrib_list[i + 1] = EGL_TRUE; | |
409 | 418 | attrib_list[i++] = EGL_NONE; |
410 | 419 | } else { |
411 | 420 | /* FIXME later */ |
412 | 421 | attrib_list[i++] = EGL_NONE; |
413 | 422 | } |
414 | 423 | |
424 | + *num_attribs = i; | |
425 | + | |
415 | 426 | return VA_STATUS_SUCCESS; |
416 | 427 | } |
417 | 428 |
@@ -1,6 +1,10 @@ | ||
1 | 1 | #ifndef _VA_EGL_IMPL_H_ |
2 | 2 | #define _VA_EGL_IMPL_H_ |
3 | 3 | |
4 | +#define IMPL_MAX_EGL_SURFACE_TARGETS 4 | |
5 | +#define IMPL_MAX_EGL_SURFACE_ATTRIBUTES 8 | |
6 | + | |
7 | + | |
4 | 8 | /** |
5 | 9 | * Initialize EGL driver context |
6 | 10 | * |