From bc9e216d7d9c49cbb7b48c0e990c415d18249909 Mon Sep 17 00:00:00 2001 From: Richard Giliam Date: Sat, 9 Jul 2022 07:03:12 +0000 Subject: [PATCH 1/2] Fix string data leaks after reading an event Prior to this commit, ion_event_stream_read_event did not completely clean up the internal string data for annotation symbols (name and import_location) and the current p_value_field_name. --- tools/events/ion_event_stream.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/events/ion_event_stream.cpp b/tools/events/ion_event_stream.cpp index 0192d9f..682cb1a 100644 --- a/tools/events/ion_event_stream.cpp +++ b/tools/events/ion_event_stream.cpp @@ -1027,6 +1027,19 @@ iERR ion_event_stream_read_event(hREADER reader, ION_EVENT_READ_PARAMS) { if (value_imports) { ion_free_owner(value_imports); } + + // Free string data for the current value_field_name. + if (p_value_field_name) { + free(value_field_name.import_location.name.value); + free(value_field_name.value.value); + } + + // Free string data associated with the annotation symbols. + for (std::vector::iterator it = value_annotations.begin(); it != value_annotations.end(); it++) { + free(it->value.value); + free(it->import_location.name.value); + } + iRETURN; } From cb0492aead383db6ea1682ca44754e74976c9db8 Mon Sep 17 00:00:00 2001 From: Richard Giliam Date: Sat, 9 Jul 2022 07:29:36 +0000 Subject: [PATCH 2/2] Fix leaked event when removing from stream --- tools/events/ion_event_stream.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/events/ion_event_stream.cpp b/tools/events/ion_event_stream.cpp index 682cb1a..248dd1a 100644 --- a/tools/events/ion_event_stream.cpp +++ b/tools/events/ion_event_stream.cpp @@ -1092,6 +1092,7 @@ iERR ion_event_stream_is_event_stream(hREADER reader, IonEventStream *stream, bo && ION_STRING_EQUALS(&ion_event_stream_marker, &symbol_value->value)) { *is_event_stream = TRUE; stream->remove(i); // Toss this event -- it's not part of the user data. + delete event; } } else if (event->event_type == STREAM_END) {