eina_unicode: return NULL if allocation fails

Reviewers: cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8785
This commit is contained in:
Vincent Torri 2019-04-30 09:23:38 +01:00 committed by Carsten Haitzler (Rasterman)
parent 0fda181e0a
commit 93070e4f0f
1 changed files with 3 additions and 0 deletions

View File

@ -116,6 +116,9 @@ eina_unicode_strndup(const Eina_Unicode *text, size_t n)
EINA_SAFETY_ON_NULL_RETURN_VAL(text, NULL);
ustr = malloc((n + 1) * sizeof(Eina_Unicode));
if (!ustr)
return NULL;
memcpy(ustr, text, n * sizeof(Eina_Unicode));
ustr[n] = 0;
return ustr;