stream_decoder.c: Fix a memory leak
authorErik de Castro Lopo <erikd@mega-nerd.com>
Sat, 8 Apr 2017 08:34:49 +0000 (18:34 +1000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Sat, 8 Apr 2017 09:15:37 +0000 (19:15 +1000)
Leak reported by Secunia Research.

src/libFLAC/stream_decoder.c

index 14d5fe7..a552751 100644 (file)
@@ -1753,6 +1753,9 @@ FLAC__bool read_metadata_vorbiscomment_(FLAC__StreamDecoder *decoder, FLAC__Stre
                                        }
                                        memset (obj->comments[i].entry, 0, obj->comments[i].length) ;
                                        if (!FLAC__bitreader_read_byte_block_aligned_no_crc(decoder->private_->input, obj->comments[i].entry, obj->comments[i].length)) {
+                                               /* Current i-th entry is bad, so we delete it. */
+                                               free (obj->comments[i].entry) ;
+                                               obj->comments[i].entry = NULL ;
                                                obj->num_comments = i;
                                                goto skip;
                                        }