forked from github/server
CID 22500 Argument cannot be negative
This commit is contained in:
parent
5887e8e48f
commit
8bc44d82ed
|
@ -833,16 +833,18 @@ static void json_include(cJSON *json) {
|
|||
F = fopen(child->valuestring, "rt");
|
||||
}
|
||||
if (F) {
|
||||
long pos;
|
||||
fseek(F, 0, SEEK_END);
|
||||
pos = ftell(F);
|
||||
rewind(F);
|
||||
if (pos > 0) {
|
||||
cJSON *config;
|
||||
char *data;
|
||||
size_t sz;
|
||||
fseek(F, 0, SEEK_END);
|
||||
sz = ftell(F);
|
||||
rewind(F);
|
||||
data = malloc(sz+1);
|
||||
sz = fread(data, 1, sz, F);
|
||||
|
||||
data = malloc(pos + 1);
|
||||
sz = fread(data, 1, (size_t)pos, F);
|
||||
data[sz] = 0;
|
||||
fclose(F);
|
||||
config = cJSON_Parse(data);
|
||||
free(data);
|
||||
if (config) {
|
||||
|
@ -853,6 +855,8 @@ static void json_include(cJSON *json) {
|
|||
log_error("invalid JSON, could not parse %s", child->valuestring);
|
||||
}
|
||||
}
|
||||
fclose(F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue