avformat/img2dec: do not rewind custom io buffers
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 20 Apr 2015 21:59:53 +0000 (23:59 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 25 Apr 2015 13:06:53 +0000 (15:06 +0200)
Fixes double free with some applications

Fixes vlc ticket14121
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit e6e8cc8ce9c2a398fbb51254a5067f4bd3c4fa8a)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/img2dec.c

index 6f10369..1509f19 100644 (file)
@@ -339,7 +339,10 @@ int ff_img_read_header(AVFormatContext *s1)
                     break;
                 }
             }
-            ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);
+            if (s1->flags & AVFMT_FLAG_CUSTOM_IO) {
+                avio_seek(s1->pb, 0, SEEK_SET);
+            } else
+                ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size);
         }
         if (st->codec->codec_id == AV_CODEC_ID_NONE)
             st->codec->codec_id = ff_guess_image2_codec(s->path);