diff mbox

[FFmpeg-devel] avformat/av1dec: check return value of the av_bsf_send_packet in annexb_read_packet

Message ID 20191114102429.26091-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Liu Steven Nov. 14, 2019, 10:24 a.m. UTC
CID: 1455685
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/av1dec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Andreas Rheinhardt Nov. 14, 2019, 11:52 a.m. UTC | #1
Steven Liu:
> CID: 1455685
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/av1dec.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
> index a0cad55668..7cbc7ef9bf 100644
> --- a/libavformat/av1dec.c
> +++ b/libavformat/av1dec.c
> @@ -193,7 +193,11 @@ retry:
>      if (avio_feof(s->pb)) {
>          if (c->temporal_unit_size || c->frame_unit_size)
>              return AVERROR(EIO);
> -        av_bsf_send_packet(c->bsf, NULL);
> +        ret = av_bsf_send_packet(c->bsf, NULL);
> +        if (ret < 0) {
> +            av_log(s, AV_LOG_ERROR, "annexb filter failed to send input packet\n");
> +            return ret;
> +        }
>          goto end;
>      }
>  
> 
Actually, there is a difference between this call and the other calls
to av_bsf_send_packet(): This one only flushes (sends a NULL packet)
and therefore can't fail.

- Andreas
James Almer Nov. 14, 2019, 1:20 p.m. UTC | #2
On 11/14/2019 7:24 AM, Steven Liu wrote:
> CID: 1455685
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/av1dec.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
> index a0cad55668..7cbc7ef9bf 100644
> --- a/libavformat/av1dec.c
> +++ b/libavformat/av1dec.c
> @@ -193,7 +193,11 @@ retry:
>      if (avio_feof(s->pb)) {
>          if (c->temporal_unit_size || c->frame_unit_size)
>              return AVERROR(EIO);
> -        av_bsf_send_packet(c->bsf, NULL);
> +        ret = av_bsf_send_packet(c->bsf, NULL);
> +        if (ret < 0) {
> +            av_log(s, AV_LOG_ERROR, "annexb filter failed to send input packet\n");
> +            return ret;
> +        }
>          goto end;
>      }

As Andreas mentioned, this is a flush call, and it can't fail. That's
why we're not checking the return value.

Can we hint Coverity about this in some form? Would setting ret followed
by the jump to the end label make it happy?
diff mbox

Patch

diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
index a0cad55668..7cbc7ef9bf 100644
--- a/libavformat/av1dec.c
+++ b/libavformat/av1dec.c
@@ -193,7 +193,11 @@  retry:
     if (avio_feof(s->pb)) {
         if (c->temporal_unit_size || c->frame_unit_size)
             return AVERROR(EIO);
-        av_bsf_send_packet(c->bsf, NULL);
+        ret = av_bsf_send_packet(c->bsf, NULL);
+        if (ret < 0) {
+            av_log(s, AV_LOG_ERROR, "annexb filter failed to send input packet\n");
+            return ret;
+        }
         goto end;
     }