Browse code

memleak (seems ive missed that under the obfuscated indention)

Originally committed as revision 8659 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2007/04/08 07:47:55
Showing 1 changed files
... ...
@@ -124,7 +124,7 @@ static int read_frame(BVID_DemuxContext *vid, ByteIOContext *pb, AVPacket *pkt,
124 124
     // set the y offset if it exists (decoder header data should be in data section)
125 125
     if(block_type == VIDEO_YOFFSET_DIFFERENCE_FRAME_BLOCK){
126 126
         if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2)
127
-            return AVERROR_IO;
127
+            goto fail;
128 128
         vidbuf_nbytes += 2;
129 129
     }
130 130
 
... ...
@@ -142,7 +142,7 @@ static int read_frame(BVID_DemuxContext *vid, ByteIOContext *pb, AVPacket *pkt,
142 142
             bytes_copied += rle_num_bytes - 0x80;
143 143
         } else if(rle_num_bytes){ // plain sequence
144 144
             if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], rle_num_bytes) != rle_num_bytes)
145
-                return AVERROR_IO;
145
+                goto fail;
146 146
             vidbuf_nbytes += rle_num_bytes;
147 147
             bytes_copied += rle_num_bytes;
148 148
         }
... ...
@@ -153,12 +153,12 @@ static int read_frame(BVID_DemuxContext *vid, ByteIOContext *pb, AVPacket *pkt,
153 153
             break;
154 154
         }
155 155
         if(bytes_copied > npixels)
156
-            return -1;    // error
156
+            goto fail;
157 157
     } while(rle_num_bytes);
158 158
 
159 159
     // copy data into packet
160
-    if(av_new_packet(pkt, vidbuf_nbytes))
161
-        return AVERROR_NOMEM;
160
+    if(av_new_packet(pkt, vidbuf_nbytes) < 0)
161
+        goto fail;
162 162
     memcpy(pkt->data, vidbuf_start, vidbuf_nbytes);
163 163
     av_free(vidbuf_start);
164 164
 
... ...
@@ -168,6 +168,9 @@ static int read_frame(BVID_DemuxContext *vid, ByteIOContext *pb, AVPacket *pkt,
168 168
 
169 169
     vid->nframes--;  // used to check if all the frames were read
170 170
     return vidbuf_nbytes;
171
+fail:
172
+    av_free(vidbuf_start);
173
+    return -1;
171 174
 }
172 175
 
173 176
 static int vid_read_packet(AVFormatContext *s,