[FFmpeg-devel] [PATCH 2/9] apngenc: Add missing error check

Mark Thompson sw at jkqxz.net
Wed Oct 18 00:12:18 EEST 2017


---
 libavformat/apngenc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c
index 77c1c916c2..16ead54cc8 100644
--- a/libavformat/apngenc.c
+++ b/libavformat/apngenc.c
@@ -217,8 +217,12 @@ static int flush_packet(AVFormatContext *format_context, AVPacket *packet)
     ++apng->frame_number;
 
     av_packet_unref(apng->prev_packet);
-    if (packet)
-        av_packet_ref(apng->prev_packet, packet);
+    if (packet) {
+        int ret;
+        ret = av_packet_ref(apng->prev_packet, packet);
+        if (ret < 0)
+            return ret;
+    }
     return 0;
 }
 
@@ -232,7 +236,9 @@ static int apng_write_packet(AVFormatContext *format_context, AVPacket *packet)
         if (!apng->prev_packet)
             return AVERROR(ENOMEM);
 
-        av_packet_ref(apng->prev_packet, packet);
+        ret = av_packet_ref(apng->prev_packet, packet);
+        if (ret < 0)
+            return ret;
     } else {
         ret = flush_packet(format_context, packet);
         if (ret < 0)
-- 
2.11.0



More information about the ffmpeg-devel mailing list