discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=0f3806efa1b2280e20f65dcf3841d8d861ed2373

commit 0f3806efa1b2280e20f65dcf3841d8d861ed2373
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Thu Aug 13 15:27:14 2015 -0400

    cnp: only nul terminate wayland drops for text type drops
    
    also move data allocation into block where dropping is guaranteed
    
    @fix
---
 src/lib/elm_cnp.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index e5e63bf..22bb770 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -3208,28 +3208,22 @@ _wl_dnd_end(void *data EINA_UNUSED, int type 
EINA_UNUSED, void *event EINA_UNUSE
    return ECORE_CALLBACK_PASS_ON;
 }
 
+static Eina_Bool
+_wl_dropable_match(Dropable_Cbs *cbs, Dropable *drop, Elm_Sel_Format fmt)
+{
+   return (cbs->types & fmt) && (drop->last.format & fmt);
+}
+
 static void
 _wl_dropable_data_handle(Wl_Cnp_Selection *sel, char *data, size_t size)
 {
    cnp_debug("In\n");
    Dropable *drop;
    Elm_Selection_Data sdata;
-   char *s = NULL;
+   char *s;
 
-   s = (char*)eina_memdup((unsigned char*)data, size, 0);
-   if (!s)
-     {
-        ecore_wl_dnd_drag_end(ecore_wl_input_get());
-        return;
-     }
    sdata.action = ELM_XDND_ACTION_COPY;
 
-   if (savedtypes.textreq)
-     {
-        savedtypes.textreq = 0;
-        savedtypes.imgfile = s;
-     }
-
    sdata.len = size;
    sdata.x = savedtypes.x;
    sdata.y = savedtypes.y;
@@ -3243,10 +3237,23 @@ _wl_dropable_data_handle(Wl_Cnp_Selection *sel, char 
*data, size_t size)
           {
              if (cbs->types & drop->last.format)
                {
-                  if ((cbs->types & ELM_SEL_FORMAT_IMAGE) && 
(drop->last.format & ELM_SEL_FORMAT_IMAGE))
+                  s = (char*)eina_memdup((unsigned char*)data, size,
+                                         _wl_dropable_match(cbs, drop, 
ELM_SEL_FORMAT_TEXT));
+                  if (!s)
+                    {
+                       ecore_wl_dnd_drag_end(ecore_wl_input_get());
+                       return;
+                    }
+
+                  if (savedtypes.textreq)
+                    {
+                       savedtypes.textreq = 0;
+                       savedtypes.imgfile = s;
+                    }
+                  if (_wl_dropable_match(cbs, drop, ELM_SEL_FORMAT_IMAGE))
                     {
                        /* If it's markup that also supports images */
-                       if ((cbs->types & ELM_SEL_FORMAT_MARKUP) && 
(drop->last.format & ELM_SEL_FORMAT_MARKUP))
+                       if (_wl_dropable_match(cbs, drop, 
ELM_SEL_FORMAT_MARKUP))
                          sdata.format = ELM_SEL_FORMAT_MARKUP;
                        else
                          sdata.format = ELM_SEL_FORMAT_IMAGE;

-- 


Reply via email to