[FFmpeg-devel] [PATCH 1/2] avcodec/dcaadpcm: check for av_malloc() failure

Nicolas George george at nsup.org
Sat Jul 22 20:55:05 EEST 2017


Le quartidi 4 thermidor, an CCXXV, foo86 a écrit :
> Fixes CID 1409915.
> ---
>  libavcodec/dcaadpcm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/dcaadpcm.c b/libavcodec/dcaadpcm.c
> index 8742c7ccf6..e00f81f011 100644
> --- a/libavcodec/dcaadpcm.c
> +++ b/libavcodec/dcaadpcm.c
> @@ -215,6 +215,9 @@ av_cold int ff_dcaadpcm_init(DCAADPCMEncContext *s)
>          return -1;
>  
>      s->private_data = av_malloc(sizeof(premultiplied_coeffs) * DCA_ADPCM_VQCODEBOOK_SZ);
> +    if (!s->private_data)

> +        return -1;

Proper return code please. Even if it is unused by the surrounding code,
it will make maintenance easier.

(There is another -1 just above, wrong too. It should be replaced by
"av_assert1(s);", but that is not important since it cannot be reached.)

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170722/3070d5c4/attachment.sig>


More information about the ffmpeg-devel mailing list