Browse code

avformat/avc: free buffer in ff_isom_write_avcc on failure

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>

James Almer authored on 2017/11/25 08:26:08
Showing 1 changed files
... ...
@@ -145,8 +145,10 @@ int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
145 145
         buf += size;
146 146
     }
147 147
 
148
-    if (!sps || !pps || sps_size < 4 || sps_size > UINT16_MAX || pps_size > UINT16_MAX)
149
-        return AVERROR_INVALIDDATA;
148
+    if (!sps || !pps || sps_size < 4 || sps_size > UINT16_MAX || pps_size > UINT16_MAX) {
149
+        ret = AVERROR_INVALIDDATA;
150
+        goto fail;
151
+    }
150 152
 
151 153
     avio_w8(pb, 1); /* version */
152 154
     avio_w8(pb, sps[1]); /* profile */
... ...
@@ -160,9 +162,11 @@ int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
160 160
     avio_w8(pb, 1); /* number of pps */
161 161
     avio_wb16(pb, pps_size);
162 162
     avio_write(pb, pps, pps_size);
163
+
164
+fail:
163 165
     av_free(start);
164 166
 
165
-    return 0;
167
+    return ret;
166 168
 }
167 169
 
168 170
 int ff_avc_write_annexb_extradata(const uint8_t *in, uint8_t **buf, int *size)