This way we don't end with an invalid stream if parsing the picture
fails.
int type, width, height;
int len, ret = 0;
- st = avformat_new_stream(s, NULL);
- if (!st)
- return AVERROR(ENOMEM);
-
pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb)
return AVERROR(ENOMEM);
goto fail;
}
+ st = avformat_new_stream(s, NULL);
+ if (!st) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
av_init_packet(&st->attached_pic);
st->attached_pic.data = data;
st->attached_pic.size = len;