]> Devoid-pointer.net GitWeb - libHPCS.git/commitdiff
Check for failed allocation, improve coding style consistency
authorMichal Malý <madcatxster@devoid-pointer.net>
Mon, 4 Apr 2016 13:40:33 +0000 (15:40 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Mon, 4 Apr 2016 13:40:33 +0000 (15:40 +0200)
libhpcs.c

index 7975784c5705fe12a3c18c07aa6fa273a46d6904..a3ee768cb29e8921aa0a970626c7605dd56d7b14 100644 (file)
--- a/libhpcs.c
+++ b/libhpcs.c
@@ -1143,7 +1143,11 @@ static enum HPCS_ParseCode __read_string_at_offset_v2(FILE* datafile, const HPCS
 
        if (str_length == 0) {
                *result = malloc(sizeof(char));
-               *result[0] = 0;
+
+               if (*result == NULL)
+                       return PARSE_E_NO_MEM;
+
+               (*result)[0] = '\0';
                return PARSE_OK;
        }