stefan pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=dc1454f8cf2ba2808caed6f7d8ab64252be26b2e

commit dc1454f8cf2ba2808caed6f7d8ab64252be26b2e
Author: Vincent Torri <[email protected]>
Date:   Tue Mar 24 14:05:19 2020 +0000

    free memory in clipboard notify event and fix clipboard clear event
    
    Reviewed-by: Mike Blumenkrantz <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D11564
---
 src/lib/ecore_win32/ecore_win32_event.c | 40 ++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/lib/ecore_win32/ecore_win32_event.c 
b/src/lib/ecore_win32/ecore_win32_event.c
index 28a5b1f07e..6ef8a6cf76 100644
--- a/src/lib/ecore_win32/ecore_win32_event.c
+++ b/src/lib/ecore_win32/ecore_win32_event.c
@@ -1953,6 +1953,18 @@ 
_ecore_win32_event_handle_delete_request(Ecore_Win32_Callback_Data *msg)
    ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
 }
 
+static void
+_ecore_win32_event_free_selection_notify(void *data EINA_UNUSED, void *ev)
+{
+   Ecore_Win32_Event_Selection_Notify *e;
+
+   e = (Ecore_Win32_Event_Selection_Notify *)ev;
+   if (e->data) free(e->data);
+   if (e->selection) free(e->selection);
+   free(e);
+}
+
+
 void
 _ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
 {
@@ -1973,12 +1985,9 @@ 
_ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
     */
    if (!_ecore_win32_clipboard_has_data)
      {
-        /* if case someone else is owning the clipboard, we can't do anything 
*/
+        /* in case someone else is owning the clipboard, we can't do anything 
*/
         if (!OpenClipboard(msg->window))
-          {
-             free(e);
-             return;
-          }
+          goto free_e;
 
         if (IsClipboardFormatAvailable(CF_UNICODETEXT))
           {
@@ -1997,7 +2006,10 @@ 
_ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
                        GlobalUnlock(global);
                        if (e->data)
                          {
-                            
ecore_event_add(ECORE_WIN32_EVENT_SELECTION_NOTIFY, e, NULL, NULL);
+                            ecore_event_add(ECORE_WIN32_EVENT_SELECTION_NOTIFY,
+                                            e,
+                                            
_ecore_win32_event_free_selection_notify,
+                                            NULL);
                             _ecore_win32_clipboard_has_data = EINA_TRUE;
                             CloseClipboard();
                             return;
@@ -2032,9 +2044,6 @@ 
_ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
                     }
                }
           }
-        free(e->data);
-        free(e->selection);
-        free(e);
         CloseClipboard();
      }
    /*
@@ -2046,15 +2055,14 @@ 
_ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
        if (!IsClipboardFormatAvailable(CF_UNICODETEXT) &&
            !IsClipboardFormatAvailable(CF_TEXT))
          {
-            e->selection = strdup("text/plain;charset=utf-8");
-            if (e->selection)
-              {
-                ecore_event_add(ECORE_WIN32_EVENT_SELECTION_CLEAR, e, NULL, 
NULL);
-                _ecore_win32_clipboard_has_data = EINA_FALSE;
-                return;
-              }
+            ecore_event_add(ECORE_WIN32_EVENT_SELECTION_CLEAR, e, NULL, NULL);
+            _ecore_win32_clipboard_has_data = EINA_FALSE;
+            return;
          }
      }
 
+ free_e:
+   if (e->data) free(e->data);
+   if (e->selection) free(e->selection);
    free(e);
 }

-- 


Reply via email to