Clean up allocated memory in JSON code

This commit is contained in:
FeRD (Frank Dana)
2019-07-11 05:00:47 -04:00
parent 8f6672be08
commit 35eb6adc55
34 changed files with 103 additions and 39 deletions

View File

@@ -345,10 +345,11 @@ Json::Value CacheMemory::JsonValue() {
Json::Value ranges;
Json::CharReaderBuilder rbuilder;
Json::CharReader* reader(rbuilder.newCharReader());
string errors;
bool success = reader->parse( json_ranges.c_str(),
json_ranges.c_str() + json_ranges.size(), &ranges, &errors );
delete reader;
if (success)
root["ranges"] = ranges;
@@ -368,6 +369,7 @@ void CacheMemory::SetJson(string value) {
string errors;
bool success = reader->parse( value.c_str(),
value.c_str() + value.size(), &root, &errors );
delete reader;
if (!success)
// Raise exception
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");