ecore_wl2: fix null dereference issue
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>
Mon, 26 Sep 2016 09:29:12 +0000 (11:29 +0200)
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>
Mon, 26 Sep 2016 11:17:24 +0000 (13:17 +0200)
if we dont get the userdata of a offer something in the protocol went
very very bad, we should not emit there a error, just return.

Also if we are getting a null offer we should dereference the nulled out
offer object.

This fixes CID 1363214

src/lib/ecore_wl2/ecore_wl2_dnd.c

index de61fdf..9138c75 100644 (file)
@@ -226,7 +226,7 @@ _ecore_wl2_dnd_enter(Ecore_Wl2_Input *input, struct wl_data_offer *offer, struct
         if (!input->drag)
           {
              ERR("Userdata of offer not found");
-             goto emit;
+             return;
           }
 
         input->drag->serial = serial;
@@ -245,14 +245,14 @@ _ecore_wl2_dnd_enter(Ecore_Wl2_Input *input, struct wl_data_offer *offer, struct
         input->drag = NULL;
      }
 
-emit:
    ev = calloc(1, sizeof(Ecore_Wl2_Event_Dnd_Enter));
    if (!ev) return;
 
    if (input->focus.keyboard)
      ev->source = input->focus.keyboard->id;
+   if (input->drag)
+     ev->win = input->drag->window_id;
 
-   ev->win = input->drag->window_id;
    ev->x = x;
    ev->y = y;
    ev->offer = input->drag;