changeset 1992:c321bada49c7 libavformat

memleak (seems ive missed that under the obfuscated indention)
author michael
date Sat, 07 Apr 2007 22:47:55 +0000
parents 999e085b50eb
children c86a5a28e1cb
files bethsoftvid.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/bethsoftvid.c	Sat Apr 07 22:41:45 2007 +0000
+++ b/bethsoftvid.c	Sat Apr 07 22:47:55 2007 +0000
@@ -124,7 +124,7 @@
     // set the y offset if it exists (decoder header data should be in data section)
     if(block_type == VIDEO_YOFFSET_DIFFERENCE_FRAME_BLOCK){
         if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
-            return AVERROR_IO;
+            goto fail;
         vidbuf_nbytes += 2;
     }
 
@@ -142,7 +142,7 @@
             bytes_copied += rle_num_bytes - 0x80;
         } else if(rle_num_bytes){ // plain sequence
             if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], rle_num_bytes) != rle_num_bytes)
-                return AVERROR_IO;
+                goto fail;
             vidbuf_nbytes += rle_num_bytes;
             bytes_copied += rle_num_bytes;
         }
@@ -153,12 +153,12 @@
             break;
         }
         if(bytes_copied > npixels)
-            return -1;    // error
+            goto fail;
     } while(rle_num_bytes);
 
     // copy data into packet
-    if(av_new_packet(pkt, vidbuf_nbytes))
-        return AVERROR_NOMEM;
+    if(av_new_packet(pkt, vidbuf_nbytes) < 0)
+        goto fail;
     memcpy(pkt->data, vidbuf_start, vidbuf_nbytes);
     av_free(vidbuf_start);
 
@@ -168,6 +168,9 @@
 
     vid->nframes--;  // used to check if all the frames were read
     return vidbuf_nbytes;
+fail:
+    av_free(vidbuf_start);
+    return -1;
 }
 
 static int vid_read_packet(AVFormatContext *s,