ogg_afh.c: Fix a memory leak.
authorAndre Noll <maan@systemlinux.org>
Thu, 13 Sep 2007 19:57:33 +0000 (21:57 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 13 Sep 2007 19:57:33 +0000 (21:57 +0200)
In a non-ogg file is passed to the ogg audio format handler, such that the
initial ogg_sync_pageout() fails, the old code leaked the memory which was
allocated for the stream_in and the stream_out pointers.

ogg_afh.c

index a9b07a3c676515f610dc678ad06aa5cfcbb06435..60af9922f45b836065d66be73e130e653705ef6b 100644 (file)
--- a/ogg_afh.c
+++ b/ogg_afh.c
@@ -131,8 +131,11 @@ static int ogg_compute_header_len(char *map, size_t numbytes,
        memcpy(buf, map, len);
        ogg_sync_wrote(sync_in, (long)len);
        ret = -E_SYNC_PAGEOUT;
-       if (ogg_sync_pageout(sync_in, &page) <= 0)
+       if (ogg_sync_pageout(sync_in, &page) <= 0) {
+               free(stream_in);
+               free(stream_out);
                goto err1;
+       }
        serial = ogg_page_serialno(&page);
        ogg_stream_init(stream_in, serial);
        ogg_stream_init(stream_out, serial);