CID 22434 Ignoring number of bytes read

also potential missing  null-termination
This commit is contained in:
Enno Rehling 2015-11-03 22:53:19 +01:00
parent 165d287d59
commit 0c5ef21c10
1 changed files with 3 additions and 2 deletions

View File

@ -839,8 +839,9 @@ static void json_include(cJSON *json) {
fseek(F, 0, SEEK_END);
sz = ftell(F);
rewind(F);
data = malloc(sz);
fread(data, 1, sz, F);
data = malloc(sz+1);
sz = fread(data, 1, sz, F);
data[sz] = 0;
fclose(F);
config = cJSON_Parse(data);
free(data);