evas: native_tbm: make sure we check for NULL before not after we dereference
authorStefan Schmidt <stefan@osg.samsung.com>
Tue, 6 Dec 2016 09:42:42 +0000 (10:42 +0100)
committerStefan Schmidt <stefan@osg.samsung.com>
Tue, 6 Dec 2016 10:05:41 +0000 (11:05 +0100)
Using *im and dereferencing it before doing the actual NULL check does not make
much sense. I kept the checks as they have been there before so the intent was
probably that they could be NULL and should be checked.

CID: 1270030, 1270029, 1270028

src/modules/evas/engines/software_generic/evas_native_tbm.c

index 7cb3595..696a728 100644 (file)
@@ -210,11 +210,12 @@ static void
 _native_bind_cb(void *image, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED)
 {
    RGBA_Image *im = image;
-   Native *n = im->native.data;
    tbm_surface_info_s info;
    tbm_surface_h tbm_surf;
 
-   if (!im || !n) return;
+   if (!im) return;
+   Native *n = im->native.data;
+   if (!n) return;
    if (n->ns.type != EVAS_NATIVE_SURFACE_TBM)
      return;
 
@@ -229,10 +230,11 @@ static void
 _native_unbind_cb(void *image)
 {
    RGBA_Image *im = image;
-   Native *n = im->native.data;
    tbm_surface_h tbm_surf;
 
-   if (!im || !n) return;
+   if (!im) return;
+   Native *n = im->native.data;
+   if (!n) return;
    if (n->ns.type != EVAS_NATIVE_SURFACE_TBM)
      return;
 
@@ -244,9 +246,9 @@ static void
 _native_free_cb(void *image)
 {
    RGBA_Image *im = image;
-   Native *n = im->native.data;
 
    if (!im) return;
+   Native *n = im->native.data;
 
    im->native.data        = NULL;
    im->native.func.bind   = NULL;