[FFmpeg-devel] [PATCH 1/3] avutil/dict: av_realloc -> av_realloc_array()

Nicolas George george at nsup.org
Sat May 30 16:32:18 EEST 2020


lance.lmwang at gmail.com (12020-05-30):
> From: Limin Wang <lance.lmwang at gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
>  libavutil/dict.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/dict.c b/libavutil/dict.c
> index 0ea7138..a1107b1 100644
> --- a/libavutil/dict.c
> +++ b/libavutil/dict.c
> @@ -103,8 +103,8 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value,
>          av_free(tag->key);
>          *tag = m->elems[--m->count];
>      } else if (copy_value) {
> -        AVDictionaryEntry *tmp = av_realloc(m->elems,
> -                                            (m->count + 1) * sizeof(*m->elems));

> +        AVDictionaryEntry *tmp = av_realloc_array(m->elems,
> +                                            m->count + 1, sizeof(*m->elems));

If you change something, make sure the alignment is correct.

>          if (!tmp)
>              goto err_out;
>          m->elems = tmp;

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200530/fe69455e/attachment.sig>


More information about the ffmpeg-devel mailing list