[gegl] Bounds check gegl_cl_errstring



commit 32604300d6dbb1f0b49d713b5f9efbba3b12d387
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Fri Jun 7 12:05:52 2013 -0700

    Bounds check gegl_cl_errstring

 gegl/opencl/gegl-cl-init.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/gegl/opencl/gegl-cl-init.c b/gegl/opencl/gegl-cl-init.c
index d96c71f..f21f480 100644
--- a/gegl/opencl/gegl-cl-init.c
+++ b/gegl/opencl/gegl-cl-init.c
@@ -106,6 +106,11 @@ const char *gegl_cl_errstring(cl_int err) {
     , "invalid global work size"        /* -63 */
   };
 
+  static const int strings_len = sizeof(strings) / sizeof(strings[0]);
+
+  if (-err < 0 || -err >= strings_len)
+    return "unknown error";
+
   return strings[-err];
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]