[FFmpeg-devel] [PATCH v1] avcodec/h2645_parse: fix for the realloc size

James Almer jamrial at gmail.com
Tue Sep 10 04:53:53 EEST 2019


On 9/9/2019 10:18 PM, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
>  libavcodec/h2645_parse.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
> index 307e8643e6..403acd2ee1 100644
> --- a/libavcodec/h2645_parse.c
> +++ b/libavcodec/h2645_parse.c
> @@ -454,7 +454,7 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
>          }
>  
>          if (pkt->nals_allocated < pkt->nb_nals + 1) {
> -            int new_size = pkt->nals_allocated + 1;
> +            int new_size = pkt->nb_nals + 1;

No. nals_allocated and nb_nals are two purposely separate values in
order to reuse the H2645Packet struct. One keeps track of the allocated
size of the NAL buffer, whereas the other keeps track of the amount of
NALs used by the current packet. That's why the check immediately above
this line makes sure the amount of NALs in the current packet fit in the
current size of the NAL buffer, and grows/reallocates it otherwise.

>              void *tmp = av_realloc_array(pkt->nals, new_size, sizeof(*pkt->nals));
>  
>              if (!tmp)
> 



More information about the ffmpeg-devel mailing list