From 8c569a96d886179c5ccc9772755f9dd09c88b60e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Mon, 4 Apr 2016 15:40:33 +0200 Subject: [PATCH] Check for failed allocation, improve coding style consistency --- libhpcs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libhpcs.c b/libhpcs.c index 7975784..a3ee768 100644 --- 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; } -- 2.43.5