• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/libva


Commit MetaInfo

Révisionc3ab994edf2a20e9e8c96dce8883c1df99b88849 (tree)
l'heure2011-12-14 09:27:03
AuteurXiang, Haihao <haihao.xiang@inte...>
CommiterXiang, Haihao

Message de Log

Array bound check

Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>

Change Summary

Modification

--- a/va/egl/va_egl.c
+++ b/va/egl/va_egl.c
@@ -183,7 +183,7 @@ int vaMaxNumSurfaceTargetsEGL(
183183 if (va_egl)
184184 return va_egl->max_egl_surface_targets;
185185 else
186- return 2;
186+ return IMPL_MAX_EGL_SURFACE_TARGETS;
187187 }
188188
189189 int vaMaxNumSurfaceAttributesEGL(
@@ -200,7 +200,7 @@ int vaMaxNumSurfaceAttributesEGL(
200200 if (va_egl)
201201 return va_egl->max_egl_surface_attributes;
202202 else
203- return 2;
203+ return IMPL_MAX_EGL_SURFACE_ATTRIBUTES;
204204 }
205205
206206 VAStatus vaQuerySurfaceTargetsEGL(
--- a/va/egl/va_egl_impl.c
+++ b/va/egl/va_egl_impl.c
@@ -282,8 +282,10 @@ vaQuerySurfaceTargetsEGL_impl_libva(VADisplay dpy,
282282 {
283283 int i = 0;
284284
285+ /* FIXME: support other targets ??? */
285286 target_list[i++] = EGL_NATIVE_PIXMAP_KHR;
286287 *num_targets = i;
288+ assert(i <= IMPL_MAX_EGL_SURFACE_TARGETS);
287289
288290 return VA_STATUS_SUCCESS;
289291 }
@@ -297,6 +299,10 @@ vaCreateSurfaceEGL_impl_libva(VADisplay dpy,
297299 {
298300 VASurfaceImplEGLP pSurfaceImplEGL = NULL;
299301
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+
300306 pSurfaceImplEGL = calloc(1, sizeof(*pSurfaceImplEGL));
301307
302308 if (!pSurfaceImplEGL) {
@@ -400,18 +406,23 @@ vaGetSurfaceInfoEGL_impl_libva(VADisplay dpy,
400406 if (pSurfaceImplEGL->surface == VA_INVALID_SURFACE)
401407 return VA_STATUS_ERROR_INVALID_SURFACE;
402408
409+ if (*num_attribs < IMPL_MAX_EGL_SURFACE_ATTRIBUTES)
410+ return VA_STATUS_ERROR_INVALID_PARAMETER;
411+
403412 *target = pSurfaceImplEGL->target;
404413 *buffer = pSurfaceImplEGL->buffer;
405414
406415 if (pSurfaceImplEGL->target == EGL_NATIVE_PIXMAP_KHR) {
407416 attrib_list[i++] = EGL_IMAGE_PRESERVED_KHR;
408- attrib_list[i++] = EGL_TRUE;
417+ attrib_list[i + 1] = EGL_TRUE;
409418 attrib_list[i++] = EGL_NONE;
410419 } else {
411420 /* FIXME later */
412421 attrib_list[i++] = EGL_NONE;
413422 }
414423
424+ *num_attribs = i;
425+
415426 return VA_STATUS_SUCCESS;
416427 }
417428
--- a/va/egl/va_egl_impl.h
+++ b/va/egl/va_egl_impl.h
@@ -1,6 +1,10 @@
11 #ifndef _VA_EGL_IMPL_H_
22 #define _VA_EGL_IMPL_H_
33
4+#define IMPL_MAX_EGL_SURFACE_TARGETS 4
5+#define IMPL_MAX_EGL_SURFACE_ATTRIBUTES 8
6+
7+
48 /**
59 * Initialize EGL driver context
610 *