avformat/utils: free existing extradata before trying to allocate a new one

This prevents leaks in the rare cases the function is called when extradata
already exists.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
pull/281/head
James Almer 7 years ago
parent b19e11a4dc
commit 0ca33b1d4e
  1. 1
      libavformat/utils.c

@ -3245,6 +3245,7 @@ int ff_alloc_extradata(AVCodecParameters *par, int size)
{
int ret;
av_freep(&par->extradata);
if (size < 0 || size >= INT32_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
par->extradata = NULL;
par->extradata_size = 0;

Loading…
Cancel
Save