share/utf8: Add missing check
authorErik de Castro Lopo <erikd@mega-nerd.com>
Sun, 31 Jan 2016 23:58:47 +0000 (10:58 +1100)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Sun, 31 Jan 2016 23:58:51 +0000 (10:58 +1100)
Patch-from: lvqcl <lvqcl.mail@gmail.com>

src/share/utf8/utf8.c

index f886e32..093067c 100644 (file)
@@ -182,6 +182,12 @@ int utf8_encode(const char *from, char **to)
         * MS doesn't actually have a consistent API across win32.
         */
        *to = (char*)make_utf8_string(unicode);
+       if(*to == NULL)
+       {
+               free(unicode);
+               fprintf(stderr, "Out of memory processing string from UNICODE16 to UTF8\n");
+               return -1;
+       }
 
        free(unicode);
        return 0;