diff mbox

[FFmpeg-devel,07/12] cngenc: Add missing error check

Message ID 20170706182842.7785-8-derek.buitenhuis@gmail.com
State New
Headers show

Commit Message

Derek Buitenhuis July 6, 2017, 6:28 p.m. UTC
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
---
 libavcodec/cngenc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Rostislav Pehlivanov July 6, 2017, 9:07 p.m. UTC | #1
On 6 July 2017 at 19:28, Derek Buitenhuis <derek.buitenhuis@gmail.com>
wrote:

> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
> ---
>  libavcodec/cngenc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c
> index 302c703f72..b7207fd5f6 100644
> --- a/libavcodec/cngenc.c
> +++ b/libavcodec/cngenc.c
> @@ -92,6 +92,8 @@ static int cng_encode_frame(AVCodecContext *avctx,
> AVPacket *avpkt,
>          qdbov = 127;
>      }
>      ret = ff_lpc_calc_ref_coefs(&p->lpc, p->samples32, p->order,
> p->ref_coef);
> +    if (ret < 0)
> +        return ret;
>      avpkt->data[0] = qdbov;
>      for (i = 0; i < p->order; i++)
>          avpkt->data[1 + i] = p->ref_coef[i] * 127 + 127;
> --
> 2.11.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Just remove setting and checking the return value altogether,
ff_lpc_calc_ref_coeffs returns the order which you give it and can't error
out. Would look good to me if you did that, so feel free to push once done.
Derek Buitenhuis July 6, 2017, 9:10 p.m. UTC | #2
On 7/6/2017 10:07 PM, Rostislav Pehlivanov wrote:
> Just remove setting and checking the return value altogether,
> ff_lpc_calc_ref_coeffs returns the order which you give it and can't error
> out. Would look good to me if you did that, so feel free to push once done.

OK.

- Derek
diff mbox

Patch

diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c
index 302c703f72..b7207fd5f6 100644
--- a/libavcodec/cngenc.c
+++ b/libavcodec/cngenc.c
@@ -92,6 +92,8 @@  static int cng_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
         qdbov = 127;
     }
     ret = ff_lpc_calc_ref_coefs(&p->lpc, p->samples32, p->order, p->ref_coef);
+    if (ret < 0)
+        return ret;
     avpkt->data[0] = qdbov;
     for (i = 0; i < p->order; i++)
         avpkt->data[1 + i] = p->ref_coef[i] * 127 + 127;