Make BongoJsonJPathGetString() allocate memory for the caller
This commit is contained in:
@@ -1208,10 +1208,7 @@ ReadConfiguration(void)
|
||||
}
|
||||
|
||||
res = BongoJsonJPathGetInt(node, "o:flags/i", &AVirus.flags);
|
||||
res = BongoJsonJPathGetString(node, "o:patterns/s", &tmpBuffer);
|
||||
if (res == BONGO_JSON_OK) {
|
||||
strncpy(AVirus.path.patterns, tmpBuffer, XPL_MAX_PATH);
|
||||
}
|
||||
res = BongoJsonJPathGetString(node, "o:patterns/s", &AVirus.path.patterns);
|
||||
res = BongoJsonJPathGetInt(node, "o:queue/i", (int *)&AVirus.nmap.queue);
|
||||
res = BongoJsonJPathGetString(node, "o:host/s", &tmpBuffer);
|
||||
if (res == BONGO_JSON_OK) {
|
||||
@@ -1220,6 +1217,7 @@ ReadConfiguration(void)
|
||||
if (he) {
|
||||
memcpy(&AVirus.clam.addr.sin_addr.s_addr, he->h_addr_list[0], sizeof(AVirus.clam.addr.sin_addr.s_addr));
|
||||
}
|
||||
MemFree(tmpBuffer);
|
||||
} else {
|
||||
AVirus.clam.addr.sin_addr.s_addr = inet_addr(CLAMAV_DEFAULT_ADDRESS);
|
||||
}
|
||||
|
||||
@@ -172,10 +172,11 @@ BongoJsonJPathGetFloat(BongoJsonNode *n, const char *path, float *val) {
|
||||
}
|
||||
BongoJsonResult
|
||||
BongoJsonJPathGetString(BongoJsonNode *n, const char *path, const char **val) {
|
||||
// caller must free the memory allocated
|
||||
BongoJsonNode *result = BongoJsonJPath(n, path);
|
||||
if (!result) return BONGO_JSON_NOT_FOUND;
|
||||
if (result->type == BONGO_JSON_STRING) {
|
||||
*val = BongoJsonNodeAsString(result);
|
||||
*val = MemStrdup(BongoJsonNodeAsString(result));
|
||||
return BONGO_JSON_OK;
|
||||
}
|
||||
return BONGO_JSON_BAD_TYPE;
|
||||
|
||||
Reference in New Issue
Block a user