jackdanielz pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=39ffbf1c921797f5885e782910fc0a14e903293a

commit 39ffbf1c921797f5885e782910fc0a14e903293a
Author: Youngbok Shin <youngb.s...@samsung.com>
Date:   Mon Jun 15 08:08:34 2015 +0300

    cnp: Add safety check for NULL pointer from malloc().
    
    Summary:
    It could make crash when malloc is failed.
    @fix
    
    Reviewers: raster, woohyun, Hermet, JackDanielZ, thiepha
    
    Subscribers: JackDanielZ
    
    Differential Revision: https://phab.enlightenment.org/D2671
---
 src/lib/elm_cnp.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index 5d32fee..22e71e1 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -1024,18 +1024,21 @@ _x11_data_preparer_uri(Ecore_X_Event_Selection_Notify 
*notify,
                   else
                     p = files->files[i];
 
-                  len = strlen(p);
-                  strcpy(s, p);
-                  if (i < (files->num_files - 1))
+                  if (s)
                     {
-                       s[len] = '\n';
-                       s[len + 1] = 0;
-                       s += len + 1;
-                    }
-                  else
-                    {
-                       s[len] = 0;
-                       s += len;
+                       len = strlen(p);
+                       strcpy(s, p);
+                       if (i < (files->num_files - 1))
+                         {
+                            s[len] = '\n';
+                            s[len + 1] = 0;
+                            s += len + 1;
+                         }
+                       else
+                         {
+                            s[len] = 0;
+                            s += len;
+                         }
                     }
 
                   if (uri[i])

-- 


Reply via email to