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

Submitted by Mark Thompson on Oct. 17, 2017, 9:12 p.m.

Details

Message ID 20171017211225.3175-2-sw@jkqxz.net
State New
Headers show

Commit Message

Mark Thompson Oct. 17, 2017, 9:12 p.m.
---
 libavformat/apngenc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer Oct. 19, 2017, 1:08 a.m.
On Tue, Oct 17, 2017 at 10:12:18PM +0100, Mark Thompson wrote:
> ---
>  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)

probably ok

thx

[...]

Patch hide | download patch | download mbox

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)