lavc/pngenc: check malloc fail before using the pointer
authorJun Zhao <barryjzhao@tencent.com>
Fri, 10 May 2019 14:28:38 +0000 (22:28 +0800)
committerJun Zhao <barryjzhao@tencent.com>
Sun, 12 May 2019 06:18:25 +0000 (14:18 +0800)
Need to check malloc fail before using the pointer

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
libavcodec/pngenc.c

index 69b4495..d4d8dc8 100644 (file)
@@ -748,11 +748,11 @@ static int apng_encode_frame(AVCodecContext *avctx, const AVFrame *pict,
     original_bytestream_end = s->bytestream_end;
 
     temp_bytestream = av_malloc(original_bytestream_end - original_bytestream);
-    temp_bytestream_end = temp_bytestream + (original_bytestream_end - original_bytestream);
     if (!temp_bytestream) {
         ret = AVERROR(ENOMEM);
         goto fail;
     }
+    temp_bytestream_end = temp_bytestream + (original_bytestream_end - original_bytestream);
 
     for (last_fctl_chunk.dispose_op = 0; last_fctl_chunk.dispose_op < 3; ++last_fctl_chunk.dispose_op) {
         // 0: APNG_DISPOSE_OP_NONE