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
This commit is contained in:
Youngbok Shin 2015-06-15 08:08:34 +03:00 committed by Daniel Zaoui
parent d04e6c7d6a
commit 6f33f4f1d1
1 changed files with 14 additions and 11 deletions

View File

@ -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])