mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +00:00
tag: id3v2: Make sure that g_free always gets called on the same pointer that was returned by g_mallo...
Original commit message from CVS: * gst-libs/gst/tag/id3v2frames.c: (id3demux_id3v2_parse_frame): Make sure that g_free always gets called on the same pointer that was returned by g_malloc. Fixes #376594. Do not leak memory if decompressed size is wrong. Remove unneeded check of return value of g_malloc. Patch by: René Stadler <mail@renestadler.de>
This commit is contained in:
parent
07feb53dbd
commit
763eea481e
1 changed files with 16 additions and 7 deletions
|
@ -73,6 +73,10 @@ id3demux_id3v2_parse_frame (ID3TagsWorking * work)
|
||||||
gchar *tag_str = NULL;
|
gchar *tag_str = NULL;
|
||||||
GArray *tag_fields = NULL;
|
GArray *tag_fields = NULL;
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
guint8 *uncompressed_data = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Check that the frame id is valid */
|
/* Check that the frame id is valid */
|
||||||
for (i = 0; i < 5 && work->frame_id[i] != '\0'; i++) {
|
for (i = 0; i < 5 && work->frame_id[i] != '\0'; i++) {
|
||||||
if (!g_ascii_isalnum (work->frame_id[i])) {
|
if (!g_ascii_isalnum (work->frame_id[i])) {
|
||||||
|
@ -121,22 +125,23 @@ id3demux_id3v2_parse_frame (ID3TagsWorking * work)
|
||||||
uLongf destSize = work->parse_size;
|
uLongf destSize = work->parse_size;
|
||||||
Bytef *dest, *src;
|
Bytef *dest, *src;
|
||||||
|
|
||||||
work->parse_data = g_malloc (work->parse_size);
|
uncompressed_data = g_malloc (work->parse_size);
|
||||||
g_return_val_if_fail (work->parse_data != NULL, FALSE);
|
|
||||||
|
|
||||||
dest = (Bytef *) work->parse_data;
|
dest = (Bytef *) uncompressed_data;
|
||||||
src = (Bytef *) frame_data;
|
src = (Bytef *) frame_data;
|
||||||
|
|
||||||
if (uncompress (dest, &destSize, src, frame_data_size) != Z_OK) {
|
if (uncompress (dest, &destSize, src, frame_data_size) != Z_OK) {
|
||||||
g_free (work->parse_data);
|
g_free (uncompressed_data);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (destSize != work->parse_size) {
|
if (destSize != work->parse_size) {
|
||||||
GST_WARNING
|
GST_WARNING
|
||||||
("Decompressing ID3v2 frame %s did not produce expected size %d bytes (got %lu)",
|
("Decompressing ID3v2 frame %s did not produce expected size %d bytes (got %lu)",
|
||||||
tag_name, work->parse_size, destSize);
|
tag_name, work->parse_size, destSize);
|
||||||
|
g_free (uncompressed_data);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
work->parse_data = uncompressed_data;
|
||||||
#else
|
#else
|
||||||
GST_WARNING ("Compressed ID3v2 tag frame could not be decompressed"
|
GST_WARNING ("Compressed ID3v2 tag frame could not be decompressed"
|
||||||
" because gstid3demux was compiled without zlib support");
|
" because gstid3demux was compiled without zlib support");
|
||||||
|
@ -167,9 +172,13 @@ id3demux_id3v2_parse_frame (ID3TagsWorking * work)
|
||||||
/* Unique file identifier */
|
/* Unique file identifier */
|
||||||
tag_str = parse_unique_file_identifier (work, &tag_name);
|
tag_str = parse_unique_file_identifier (work, &tag_name);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
if (work->frame_flags & ID3V2_FRAME_FORMAT_COMPRESSION)
|
if (work->frame_flags & ID3V2_FRAME_FORMAT_COMPRESSION) {
|
||||||
g_free (work->parse_data);
|
g_free (uncompressed_data);
|
||||||
|
uncompressed_data = NULL;
|
||||||
|
work->parse_data = frame_data;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (tag_str != NULL) {
|
if (tag_str != NULL) {
|
||||||
/* g_print ("Tag %s value %s\n", tag_name, tag_str); */
|
/* g_print ("Tag %s value %s\n", tag_name, tag_str); */
|
||||||
|
|
Loading…
Reference in a new issue