Skip to content

Commit 35eb6ad

Browse files
committed
Clean up allocated memory in JSON code
1 parent 8f6672b commit 35eb6ad

34 files changed

+103
-39
lines changed

src/CacheDisk.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ Json::Value CacheDisk::JsonValue() {
495495
string errors;
496496
bool success = reader->parse( json_ranges.c_str(),
497497
json_ranges.c_str() + json_ranges.size(), &ranges, &errors );
498+
delete reader;
499+
498500
if (success)
499501
root["ranges"] = ranges;
500502

@@ -512,7 +514,9 @@ void CacheDisk::SetJson(string value) {
512514

513515
string errors;
514516
bool success = reader->parse( value.c_str(),
515-
value.c_str() + value.size(), &root, &errors );
517+
value.c_str() + value.size(), &root, &errors );
518+
delete reader;
519+
516520
if (!success)
517521
// Raise exception
518522
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/CacheMemory.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,11 @@ Json::Value CacheMemory::JsonValue() {
345345
Json::Value ranges;
346346
Json::CharReaderBuilder rbuilder;
347347
Json::CharReader* reader(rbuilder.newCharReader());
348-
348+
349349
string errors;
350350
bool success = reader->parse( json_ranges.c_str(),
351351
json_ranges.c_str() + json_ranges.size(), &ranges, &errors );
352+
delete reader;
352353

353354
if (success)
354355
root["ranges"] = ranges;
@@ -368,6 +369,7 @@ void CacheMemory::SetJson(string value) {
368369
string errors;
369370
bool success = reader->parse( value.c_str(),
370371
value.c_str() + value.size(), &root, &errors );
372+
delete reader;
371373
if (!success)
372374
// Raise exception
373375
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/ChunkReader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,11 @@ void ChunkReader::SetJson(string value) {
285285
Json::Value root;
286286
Json::CharReaderBuilder rbuilder;
287287
Json::CharReader* reader(rbuilder.newCharReader());
288-
288+
289289
string errors;
290290
bool success = reader->parse( value.c_str(),
291291
value.c_str() + value.size(), &root, &errors );
292+
delete reader;
292293
if (!success)
293294
// Raise exception
294295
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/Clip.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,12 @@ void Clip::SetJson(string value) {
796796
Json::Value root;
797797
Json::CharReaderBuilder rbuilder;
798798
Json::CharReader* reader(rbuilder.newCharReader());
799-
799+
800800
string errors;
801801
bool success = reader->parse( value.c_str(),
802802
value.c_str() + value.size(), &root, &errors );
803+
delete reader;
804+
803805
if (!success)
804806
// Raise exception
805807
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/Color.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ void Color::SetJson(string value) {
116116
string errors;
117117
bool success = reader->parse( value.c_str(),
118118
value.c_str() + value.size(), &root, &errors );
119+
delete reader;
120+
119121
if (!success)
120122
// Raise exception
121123
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/Coordinate.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ void Coordinate::SetJson(string value) {
7777
Json::CharReader* reader(rbuilder.newCharReader());
7878

7979
string errors;
80-
bool success = reader->parse( value.c_str(),
80+
bool success = reader->parse( value.c_str(),
8181
value.c_str() + value.size(), &root, &errors );
82+
delete reader;
83+
8284
if (!success)
8385
// Raise exception
8486
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/DecklinkReader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,10 @@ void DecklinkReader::SetJson(string value) {
272272
Json::CharReader* reader(rbuilder.newCharReader());
273273

274274
string errors;
275-
bool success = reader->parse( value.c_str(),
275+
bool success = reader->parse( value.c_str(),
276276
value.c_str() + value.size(), &root, &errors );
277+
delete reader;
278+
277279
if (!success)
278280
// Raise exception
279281
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/DummyReader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ void DummyReader::SetJson(string value) {
150150
Json::CharReader* reader(rbuilder.newCharReader());
151151

152152
string errors;
153-
bool success = reader->parse( value.c_str(),
153+
bool success = reader->parse( value.c_str(),
154154
value.c_str() + value.size(), &root, &errors );
155+
delete reader;
156+
155157
if (!success)
156158
// Raise exception
157159
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/EffectBase.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ void EffectBase::SetJson(string value) {
106106
Json::CharReader* reader(rbuilder.newCharReader());
107107

108108
string errors;
109-
bool success = reader->parse( value.c_str(),
109+
bool success = reader->parse( value.c_str(),
110110
value.c_str() + value.size(), &root, &errors );
111+
delete reader;
112+
111113
if (!success)
112114
// Raise exception
113115
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

src/FFmpegReader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,8 @@ void FFmpegReader::SetJson(string value) {
24312431
string errors;
24322432
bool success = reader->parse(value.c_str(), value.c_str() + value.size(),
24332433
&root, &errors);
2434+
delete reader;
2435+
24342436
if (!success)
24352437
// Raise exception
24362438
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");

0 commit comments

Comments
 (0)