[Gegl-developer] [PATCH 1/1] video-degradation: Don't crash when CL build fails



Signed-off-by: Jan Vesely <jan vesely rutgers edu>
---
 operations/common/video-degradation.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/operations/common/video-degradation.c b/operations/common/video-degradation.c
index 29197ff..5b84e2a 100644
--- a/operations/common/video-degradation.c
+++ b/operations/common/video-degradation.c
@@ -201,13 +201,17 @@ cl_process (GeglOperation       *operation,
   const size_t gbl_size[2] = {roi->width, roi->height};
   const size_t gbl_off[2]  = {roi->x, roi->y};
   cl_int cl_err = 0;
+  cl_mem filter_pat = NULL;
 
-  cl_mem filter_pat = gegl_clCreateBuffer (gegl_cl_get_context (),
-                                           CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
-                                           pattern_width[o->pattern] *
-                                           pattern_height[o->pattern] * sizeof(cl_int),
-                                           (void*)pattern[o->pattern],
-                                           &cl_err);
+  if (!cl_data)
+    goto error;
+
+  filter_pat = gegl_clCreateBuffer (gegl_cl_get_context (),
+                                    CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
+                                    pattern_width[o->pattern] *
+                                    pattern_height[o->pattern] * sizeof(cl_int),
+                                    (void*)pattern[o->pattern],
+                                    &cl_err);
   CL_CHECK;
   cl_err = gegl_cl_set_kernel_args (cl_data->kernel[0],
                                     sizeof(cl_mem), &in_buf,
-- 
2.5.5



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