gl_x11/evas_engine: Prevent dereference before NULL check
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Wed, 28 May 2014 05:32:39 +0000 (14:32 +0900)
committerChunEon Park <hermet@hermet.pe.kr>
Wed, 28 May 2014 05:32:39 +0000 (14:32 +0900)
Summary: re->win pointer was not compared with NULL pointer before re->win was referenced.

Reviewers: Hermet

Reviewed By: Hermet

CC: seoz, cedric
Differential Revision: https://phab.enlightenment.org/D910

src/modules/evas/engines/gl_x11/evas_engine.c

index 37faaa53d7f1a2ec3e96c48e78738eb93e591fc0..a4391b5dfa7bf9a54987211db698451c9b81fc82 100644 (file)
@@ -929,7 +929,7 @@ eng_setup(Evas *eo_e, void *in)
    else
      {
         re = e->engine.data.output;
-        if (_re_wincheck(re))
+        if (re->win && _re_wincheck(re))
           {
              if ((re->info->info.display != re->win->disp) ||
                  (re->info->info.drawable != re->win->win) ||
@@ -939,15 +939,10 @@ eng_setup(Evas *eo_e, void *in)
                  (re->info->info.depth != re->win->depth) ||
                  (re->info->info.destination_alpha != re->win->alpha))
                {
-                  int inc = 0;
+                  re->win->gl_context->references++;
+                  eng_window_free(re->win);
+                  gl_wins--;
 
-                  if (re->win)
-                    {
-                       re->win->gl_context->references++;
-                       eng_window_free(re->win);
-                       inc = 1;
-                       gl_wins--;
-                    }
                   re->w = e->output.w;
                   re->h = e->output.h;
                   re->win = eng_window_new(re->info->info.display,
@@ -962,9 +957,11 @@ eng_setup(Evas *eo_e, void *in)
                                            re->info->info.destination_alpha,
                                            re->info->info.rotation);
                   eng_window_use(re->win);
-                  if (re->win) gl_wins++;
-                  if ((re->win) && (inc))
-                     re->win->gl_context->references--;
+                  if (re->win)
+                    {
+                       gl_wins++;
+                       re->win->gl_context->references--;
+                    }
                }
              else if ((re->win->w != e->output.w) ||
                       (re->win->h != e->output.h) ||