]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/v210enc.c
v210enc: check return value of avcodec_alloc_frame()
[ffmpeg] / libavcodec / v210enc.c
index 92577ef80f8c0fcfa48ae1588795a66f00cfd324..bcfe0717c4fc1b29c81a90c72134eef9574a28ea 100644 (file)
@@ -41,6 +41,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
                avctx->bits_per_raw_sample);
 
     avctx->coded_frame = avcodec_alloc_frame();
+    if (!avctx->coded_frame)
+        return AVERROR(ENOMEM);
 
     avctx->coded_frame->key_frame = 1;
     avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
@@ -90,13 +92,13 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
             val = CLIP(*y++);
             if (w == avctx->width - 2)
                 bytestream_put_le32(&p, val);
-        }
-        if (w < avctx->width - 3) {
-            val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
-            bytestream_put_le32(&p, val);
+            if (w < avctx->width - 3) {
+                val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);
+                bytestream_put_le32(&p, val);
 
-            val = CLIP(*v++) | (CLIP(*y++) << 10);
-            bytestream_put_le32(&p, val);
+                val = CLIP(*v++) | (CLIP(*y++) << 10);
+                bytestream_put_le32(&p, val);
+            }
         }
 
         pdst += stride;