efl_ui_win: Fix dereference before NULL check
authorChristopher Michael <devilhorns@comcast.net>
Fri, 6 Mar 2020 21:12:15 +0000 (16:12 -0500)
committerTaehyub Kim <taehyub.kim@samsung.com>
Tue, 10 Mar 2020 10:51:11 +0000 (19:51 +0900)
This patch fixes an issue detected by Coverity in that 'sdp' is
already being dereferenced before we check it. ELM_WIN_DATA_GET can
return NULL, so we should check it's return Before trying to use the
variable.

Fixes CID1419871

src/lib/elementary/efl_ui_win.c

index c0e9a9f..cd84eb7 100644 (file)
@@ -61,7 +61,7 @@ static int _paused_windows = 0;
   while (0)
 
 #define ELM_WIN_DATA_GET(o, sd) \
-  Efl_Ui_Win_Data * sd = efl_data_scope_get(o, MY_CLASS)
+  Efl_Ui_Win_Data *sd = efl_data_scope_get(o, MY_CLASS)
 
 #define ELM_WIN_DATA_GET_OR_RETURN(o, ptr, ...)      \
   ELM_WIN_DATA_GET(o, ptr);                          \
@@ -4186,8 +4186,11 @@ _elm_win_xwin_update(Efl_Ui_Win_Data *sd)
         if (sd->parent)
           {
              ELM_WIN_DATA_GET(sd->parent, sdp);
-             _internal_elm_win_xwindow_get(sdp);
-             if (sdp) ecore_x_icccm_transient_for_set(sd->x.xwin, sdp->x.xwin);
+             if (sdp)
+               {
+                  _internal_elm_win_xwindow_get(sdp);
+                  ecore_x_icccm_transient_for_set(sd->x.xwin, sdp->x.xwin);
+               }
           }
      }