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");
|
F = fopen(child->valuestring, "rt");
|
||||||
}
|
}
|
||||||
if (F) {
|
if (F) {
|
||||||
|
long pos;
|
||||||
|
fseek(F, 0, SEEK_END);
|
||||||
|
pos = ftell(F);
|
||||||
|
rewind(F);
|
||||||
|
if (pos > 0) {
|
||||||
cJSON *config;
|
cJSON *config;
|
||||||
char *data;
|
char *data;
|
||||||
size_t sz;
|
size_t sz;
|
||||||
fseek(F, 0, SEEK_END);
|
|
||||||
sz = ftell(F);
|
data = malloc(pos + 1);
|
||||||
rewind(F);
|
sz = fread(data, 1, (size_t)pos, F);
|
||||||
data = malloc(sz+1);
|
|
||||||
sz = fread(data, 1, sz, F);
|
|
||||||
data[sz] = 0;
|
data[sz] = 0;
|
||||||
fclose(F);
|
|
||||||
config = cJSON_Parse(data);
|
config = cJSON_Parse(data);
|
||||||
free(data);
|
free(data);
|
||||||
if (config) {
|
if (config) {
|
||||||
|
@ -853,6 +855,8 @@ static void json_include(cJSON *json) {
|
||||||
log_error("invalid JSON, could not parse %s", child->valuestring);
|
log_error("invalid JSON, could not parse %s", child->valuestring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fclose(F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue