1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00

demux_mkv: Fix memory leaks in attachment reading

When the attachment-reading code was changed to use
demuxer_add_attachment it should have been changed to free its
internally-allocated objects too, since demuxer_add_attachment creates
copies of everything and leaves ownership of original objects to
caller.
This commit is contained in:
Uoti Urpala 2009-09-18 06:12:19 +03:00
parent e1ecc43152
commit b05d9ead6d

View File

@ -1319,17 +1319,19 @@ demux_mkv_read_attachments (demuxer_t *demuxer)
switch (ebml_read_id (s, &il))
{
case MATROSKA_ID_FILENAME:
free(name);
name = ebml_read_utf8 (s, &l);
if (name == NULL)
return 0;
goto error;
mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileName: %s\n",
name);
break;
case MATROSKA_ID_FILEMIMETYPE:
free(mime);
mime = ebml_read_ascii (s, &l);
if (mime == NULL)
return 0;
goto error;
mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileMimeType: %s\n",
mime);
break;
@ -1343,7 +1345,10 @@ demux_mkv_read_attachments (demuxer_t *demuxer)
data = malloc (num);
if (stream_read(s, data, num) != (int) num)
{
error:
free(data);
free(mime);
free(name);
return 0;
}
data_size = num;
@ -1360,6 +1365,9 @@ demux_mkv_read_attachments (demuxer_t *demuxer)
}
demuxer_add_attachment(demuxer, name, mime, data, data_size);
free(data);
free(mime);
free(name);
mp_msg(MSGT_DEMUX, MSGL_V,
"[mkv] Attachment: %s, %s, %u bytes\n",
name, mime, data_size);