Commit dba5b06e authored by Anton Khirnov's avatar Anton Khirnov

flacdec: don't create an attached picture stream until we have all information.

This way we don't end with an invalid stream if parsing the picture
fails.
parent fdaad635
...@@ -38,10 +38,6 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) ...@@ -38,10 +38,6 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
int type, width, height; int type, width, height;
int len, ret = 0; 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); pb = avio_alloc_context(buf, buf_size, 0, NULL, NULL, NULL, NULL);
if (!pb) if (!pb)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
...@@ -114,6 +110,12 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size) ...@@ -114,6 +110,12 @@ static int parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
goto fail; goto fail;
} }
st = avformat_new_stream(s, NULL);
if (!st) {
ret = AVERROR(ENOMEM);
goto fail;
}
av_init_packet(&st->attached_pic); av_init_packet(&st->attached_pic);
st->attached_pic.data = data; st->attached_pic.data = data;
st->attached_pic.size = len; st->attached_pic.size = len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment