]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/mpjpegdec.c
Merge commit 'a31c4b2cbef9aee15910fc3df52519aef46760de'
[ffmpeg] / libavformat / mpjpegdec.c
index 8a05c9b7068be7249d3c382648e66b6342ea49fd..b8281fc2c18bc0ef19ebe3dec31178a2b09b52ba 100644 (file)
@@ -83,13 +83,13 @@ static int mpjpeg_read_probe(AVProbeData *p)
     char line[128] = { 0 };
     int ret = 0;
 
+    if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
+        return 0;
+
     pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL);
     if (!pb)
         return AVERROR(ENOMEM);
 
-    if (p->buf_size < 2 || p->buf[0] != '-' || p->buf[1] != '-')
-        return 0;
-
     while (!pb->eof_reached) {
         ret = get_line(pb, line, sizeof(line));
         if (ret < 0)
@@ -123,6 +123,8 @@ static int mpjpeg_read_header(AVFormatContext *s)
         return AVERROR_INVALIDDATA;
 
     st = avformat_new_stream(s, NULL);
+    if (!st)
+        return AVERROR(ENOMEM);
 
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->codec_id   = AV_CODEC_ID_MJPEG;