avcodec/cbs_mpeg2: fix leak of extra_information_slice buffer in cbs_mpeg2_read_slice_header()

cbs_mpeg2_free_slice() calls av_buffer_unref() on extra_information_ref,
meaning allocating with av_malloc() was not the intention.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2019-05-22 03:04:38 +02:00 committed by Mark Thompson
parent 1759a9e5b5
commit d903c09d9a
1 changed files with 4 additions and 3 deletions

View File

@ -377,10 +377,11 @@ static int FUNC(slice_header)(CodedBitstreamContext *ctx, RWContext *rw,
current->extra_information_length = k; current->extra_information_length = k;
if (k > 0) { if (k > 0) {
*rw = start; *rw = start;
current->extra_information = current->extra_information_ref =
av_malloc(current->extra_information_length); av_buffer_alloc(current->extra_information_length);
if (!current->extra_information) if (!current->extra_information_ref)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
current->extra_information = current->extra_information_ref->data;
for (k = 0; k < current->extra_information_length; k++) { for (k = 0; k < current->extra_information_length; k++) {
xui(1, extra_bit_slice, bit, 1, 1, 0); xui(1, extra_bit_slice, bit, 1, 1, 0);
xui(8, extra_information_slice[k], xui(8, extra_information_slice[k],