mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 01:22:30 +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:
parent
e1ecc43152
commit
b05d9ead6d
@ -1319,17 +1319,19 @@ demux_mkv_read_attachments (demuxer_t *demuxer)
|
|||||||
switch (ebml_read_id (s, &il))
|
switch (ebml_read_id (s, &il))
|
||||||
{
|
{
|
||||||
case MATROSKA_ID_FILENAME:
|
case MATROSKA_ID_FILENAME:
|
||||||
|
free(name);
|
||||||
name = ebml_read_utf8 (s, &l);
|
name = ebml_read_utf8 (s, &l);
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return 0;
|
goto error;
|
||||||
mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileName: %s\n",
|
mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileName: %s\n",
|
||||||
name);
|
name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MATROSKA_ID_FILEMIMETYPE:
|
case MATROSKA_ID_FILEMIMETYPE:
|
||||||
|
free(mime);
|
||||||
mime = ebml_read_ascii (s, &l);
|
mime = ebml_read_ascii (s, &l);
|
||||||
if (mime == NULL)
|
if (mime == NULL)
|
||||||
return 0;
|
goto error;
|
||||||
mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileMimeType: %s\n",
|
mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] | + FileMimeType: %s\n",
|
||||||
mime);
|
mime);
|
||||||
break;
|
break;
|
||||||
@ -1343,7 +1345,10 @@ demux_mkv_read_attachments (demuxer_t *demuxer)
|
|||||||
data = malloc (num);
|
data = malloc (num);
|
||||||
if (stream_read(s, data, num) != (int) num)
|
if (stream_read(s, data, num) != (int) num)
|
||||||
{
|
{
|
||||||
|
error:
|
||||||
free(data);
|
free(data);
|
||||||
|
free(mime);
|
||||||
|
free(name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
data_size = num;
|
data_size = num;
|
||||||
@ -1360,6 +1365,9 @@ demux_mkv_read_attachments (demuxer_t *demuxer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
demuxer_add_attachment(demuxer, name, mime, data, data_size);
|
demuxer_add_attachment(demuxer, name, mime, data, data_size);
|
||||||
|
free(data);
|
||||||
|
free(mime);
|
||||||
|
free(name);
|
||||||
mp_msg(MSGT_DEMUX, MSGL_V,
|
mp_msg(MSGT_DEMUX, MSGL_V,
|
||||||
"[mkv] Attachment: %s, %s, %u bytes\n",
|
"[mkv] Attachment: %s, %s, %u bytes\n",
|
||||||
name, mime, data_size);
|
name, mime, data_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user