On Mon, Jul 29, 2013 at 04:15:41PM +0200, Alexandra Khirnova wrote:
> --- a/libavformat/cutils.c
> +++ b/libavformat/cutils.c
> @@ -35,11 +35,14 @@ void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, 
> intptr_t elem)
>              nb_alloc = nb * 2;
> -        tab = av_realloc(tab, nb_alloc * sizeof(intptr_t));
> +        if (av_reallocp(&tab, nb_alloc * sizeof(intptr_t)) < 0)
> +            return AVERROR(ENOMEM);

av_reallocp already returns an error code.  I suggest forwarding that
instead of setting a fresh one.

> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -50,12 +50,14 @@ do {\
>      __typeof__(tab) _tab = (tab);\
>      __typeof__(elem) _elem = (elem);\
>      (void)sizeof(**_tab == _elem); /* check that types are compatible */\
> -    ff_dynarray_add((intptr_t **)_tab, nb_ptr, (intptr_t)_elem);\
> +    if (ff_dynarray_add((intptr_t **)_tab, nb_ptr, (intptr_t)_elem) < 0)\
> +    return AVERROR(ENOMEM);                                             \
>  } while(0)
>  #else
>  #define dynarray_add(tab, nb_ptr, elem)\
>  do {\
> -    ff_dynarray_add((intptr_t **)(tab), nb_ptr, (intptr_t)(elem));\
> +    if (ff_dynarray_add((intptr_t **)(tab), nb_ptr, (intptr_t)(elem)) < 0)\
> +    return AVERROR(ENOMEM);                                               \
>  } while(0)

same here

And don't forget to indent the return.

Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to