zmike pushed a commit to branch master.

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

commit e0f5e80f7831c930d432c9991d831cbd4f48babd
Author: Vincent Torri <[email protected]>
Date:   Thu Mar 26 10:47:34 2020 -0400

    fix segfault when there is no text in clipboard
    
    Test Plan: cnp a clipboard content without text
    
    Reviewers: zmike
    
    Reviewed By: zmike
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D11565
---
 .../ecore_evas/engines/win32/ecore_evas_win32.c    | 30 +++++++++++++---------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c 
b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
index 7f6eb98e48..41a0fad65e 100644
--- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
+++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
@@ -1292,22 +1292,28 @@ _ecore_evas_win32_selection_request(Ecore_Evas *ee 
EINA_UNUSED, unsigned int sea
         Eina_Rw_Slice slice;
 
         data = ecore_win32_clipboard_get((Ecore_Win32_Window 
*)ee->prop.window, &size, mime_type);
-        if (eina_str_has_prefix(mime_type, "text/"))
+        if (size != 0)
           {
-             //ensure that we always have a \0 at the end, there is no 
assertion that \0 is included here.
-             slice.len = size + 1;
-             slice.mem = eina_memdup(data, size, EINA_TRUE);
+             if (eina_str_has_prefix(mime_type, "text/"))
+               {
+                  //ensure that we always have a \0 at the end, there is no 
assertion that \0 is included here.
+                 slice.len = size + 1;
+                 slice.mem = eina_memdup(data, size, EINA_TRUE);
+                 free(data);
+               }
+             else
+               {
+                  slice.len = size;
+                  slice.mem = data;
+               }
+             content = eina_content_new(eina_rw_slice_slice_get(slice), 
mime_type);
+             if (!content) // construction can fail because of some validation 
reasons
+               eina_promise_reject(promise, ecore_evas_no_matching_type);
+             else
+               eina_promise_resolve(promise, eina_value_content_init(content));
           }
         else
-          {
-             slice.len = size;
-             slice.mem = data;
-          }
-        content = eina_content_new(eina_rw_slice_slice_get(slice), mime_type);
-        if (!content) // construction can fail because of some validation 
reasons
           eina_promise_reject(promise, ecore_evas_no_matching_type);
-        else
-          eina_promise_resolve(promise, eina_value_content_init(content));
      }
    return future;
 }

-- 


Reply via email to