]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ptx.c
mpeg12: disable checked reader.
[ffmpeg] / libavcodec / ptx.c
index 4e5453e715a56a14e7ea28e1602980b64a1f19f3..f3bca86db227d5183097c905295ee17d19b1db75 100644 (file)
@@ -60,7 +60,6 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
 
     avctx->pix_fmt = PIX_FMT_RGB555;
 
-
     if (buf_end - buf < offset)
         return AVERROR_INVALIDDATA;
     if (offset != 0x2c)
@@ -85,9 +84,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     ptr    = p->data[0];
     stride = p->linesize[0];
 
-    for (y=0; y<h; y++) {
-        if (buf_end - buf < w * bytes_per_pixel)
-            break;
+    for (y = 0; y < h && buf_end - buf >= w * bytes_per_pixel; y++) {
 #if HAVE_BIGENDIAN
         unsigned int x;
         for (x=0; x<w*bytes_per_pixel; x+=bytes_per_pixel)
@@ -102,6 +99,11 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     *picture = s->picture;
     *data_size = sizeof(AVPicture);
 
+    if (y < h) {
+        av_log(avctx, AV_LOG_WARNING, "incomplete packet\n");
+        return avpkt->size;
+    }
+
     return offset + w*h*bytes_per_pixel;
 }