elm cnp: fix freeing selection buf
authorDaniel Hirt <daniel.hirt@samsung.com>
Tue, 4 Feb 2014 13:02:54 +0000 (15:02 +0200)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Sun, 9 Feb 2014 11:22:24 +0000 (13:22 +0200)
Moved a misplaced ELM_SAFE_FREE of the selection buffer,
 as valgrind still showed lost bytes with selection.

legacy/elementary/src/lib/elm_cnp.c

index a23562f..f488003 100644 (file)
@@ -1752,12 +1752,12 @@ _x11_elm_cnp_selection_set(Ecore_X_Window xwin, Evas_Object *obj, Elm_Sel_Type s
    evas_object_event_callback_add
      (sel->widget, EVAS_CALLBACK_DEL, _x11_sel_obj_del, sel);
 
+   ELM_SAFE_FREE(sel->selbuf, free);
    if (selbuf)
      {
         if (format == ELM_SEL_FORMAT_IMAGE)
           {
              // selbuf is actual image data, not text/string
-             ELM_SAFE_FREE(sel->selbuf, free);
              sel->selbuf = malloc(buflen + 1);
              if (!sel->selbuf)
                {
@@ -1770,8 +1770,6 @@ _x11_elm_cnp_selection_set(Ecore_X_Window xwin, Evas_Object *obj, Elm_Sel_Type s
         else
           sel->selbuf = strdup((char*)selbuf);
      }
-   else
-     sel->selbuf = NULL;
 
    return EINA_TRUE;
 }