Commit 45991a80 authored by Laurent Aimar's avatar Laurent Aimar

Fixed a segfault and a possible memory leak in xml_reader_t API

 xml_ReaderReset(reader, NULL) followed by xml_ReaderDelete(reader) lead
to a double free.
 xml_ReaderReset(reader, stream) would leak the module upon error.
parent 295b0e07
...@@ -98,7 +98,9 @@ xml_reader_t *xml_ReaderCreate(vlc_object_t *obj, stream_t *stream) ...@@ -98,7 +98,9 @@ xml_reader_t *xml_ReaderCreate(vlc_object_t *obj, stream_t *stream)
*/ */
void xml_ReaderDelete(xml_reader_t *reader) void xml_ReaderDelete(xml_reader_t *reader)
{ {
module_unneed(reader, reader->p_module); if (reader->p_stream)
module_stop(reader, reader->p_module);
module_release(reader->p_module);
vlc_object_release(reader); vlc_object_release(reader);
} }
...@@ -123,6 +125,7 @@ xml_reader_t *xml_ReaderReset(xml_reader_t *reader, stream_t *stream) ...@@ -123,6 +125,7 @@ xml_reader_t *xml_ReaderReset(xml_reader_t *reader, stream_t *stream)
reader->p_stream = stream; reader->p_stream = stream;
if ((stream != NULL) && module_start(reader, reader->p_module)) if ((stream != NULL) && module_start(reader, reader->p_module))
{ {
module_release(reader->p_module);
vlc_object_release(reader); vlc_object_release(reader);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment