---
 libavformat/img2.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavformat/img2.c b/libavformat/img2.c
index 1d50fbf..ad03daa 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -198,14 +198,15 @@ enum CodecID av_guess_image2_codec(const char *filename){
 static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
 {
     VideoData *s = s1->priv_data;
-    int first_index, last_index;
+    int first_index, last_index, ret = 0;
     AVStream *st;
 
     s1->ctx_flags |= AVFMTCTX_NOHEADER;
 
     st = av_new_stream(s1, 0);
     if (!st) {
-        return AVERROR(ENOMEM);
+        ret = AVERROR(ENOMEM);
+        goto fail;
     }
 
     av_strlcpy(s->path, s1->filename, sizeof(s->path));
@@ -232,8 +233,10 @@ static int read_header(AVFormatContext *s1, 
AVFormatParameters *ap)
     }
 
     if (!s->is_pipe) {
-        if (find_image_range(&first_index, &last_index, s->path) < 0)
-            return AVERROR(ENOENT);
+        if (find_image_range(&first_index, &last_index, s->path) < 0) {
+            ret = AVERROR(ENOENT);
+            goto fail;
+        }
         s->img_first = first_index;
         s->img_last = last_index;
         s->img_number = first_index;
@@ -255,7 +258,8 @@ static int read_header(AVFormatContext *s1, 
AVFormatParameters *ap)
     if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ap->pix_fmt != 
PIX_FMT_NONE)
         st->codec->pix_fmt = ap->pix_fmt;
 
-    return 0;
+fail:
+    return ret;
 }
 
 static int read_packet(AVFormatContext *s1, AVPacket *pkt)
-- 
1.7.5.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to