cnp: Add safety check for NULL pointer from strdup().

Summary:
It could make crash when strdup() is failed.
CID - 329115
@fix

Reviewers: raster, thiepha, woohyun, Hermet

Differential Revision: https://phab.enlightenment.org/D2673
This commit is contained in:
Youngbok Shin 2015-06-12 11:02:05 +03:00 committed by Daniel Zaoui
parent 9fba74ea72
commit 61fe7e5f39
1 changed files with 8 additions and 0 deletions

View File

@ -1316,6 +1316,14 @@ _x11_text_converter(char *target, void *data, int size, void **data_ret, int *si
(const char **)data_ret, NULL);
if (!*data_ret) *data_ret = strdup("No file");
else *data_ret = strdup(*data_ret);
if (!*data_ret)
{
ERR("Failed to allocate memory!");
*size_ret = 0;
return EINA_FALSE;
}
*size_ret = strlen(*data_ret);
}
return EINA_TRUE;