eina_unicode: return NULL if allocation fails
authorVincent Torri <vincent.torri@gmail.com>
Tue, 30 Apr 2019 08:23:38 +0000 (09:23 +0100)
committerHermet Park <hermetpark@gmail.com>
Wed, 8 May 2019 04:23:36 +0000 (13:23 +0900)
Reviewers: cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8785

src/lib/eina/eina_unicode.c

index adec87a..0bb70ff 100644 (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;