evas-gl-image: Fix dereference after null check
authorChris Michael <cp.michael@samsung.com>
Thu, 5 Oct 2017 13:54:03 +0000 (09:54 -0400)
committerChris Michael <cp.michael@samsung.com>
Thu, 5 Oct 2017 13:54:03 +0000 (09:54 -0400)
Coverity reports passing a null pointer 'im->gc' to
evas_gl_common_context_flush which directly dereferences it, so lets
be sure that 'im->gc' is valid before passing it to context_flush

Fixes CID1374273

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/modules/evas/engines/gl_common/evas_gl_image.c

index ca305cf..f4ea8e1 100644 (file)
@@ -766,7 +766,7 @@ evas_gl_common_image_cache_flush(Evas_Engine_GL_Context *gc)
 EAPI void
 evas_gl_common_image_free(Evas_GL_Image *im)
 {
-   if (!im) return ;
+   if (!im) return;
 
    im->references--;
    if (im->references > 0) return;
@@ -781,7 +781,8 @@ evas_gl_common_image_free(Evas_GL_Image *im)
         im->fglyph->ext_dat_free = NULL;
      }
 
-   evas_gl_common_context_flush(im->gc);
+   if (im->gc)
+     evas_gl_common_context_flush(im->gc);
 
    evas_gl_common_image_preload_unwatch(im);