Commit 572e1eb6 authored by Julian Scheel's avatar Julian Scheel Committed by Rémi Denis-Courmont

mmal/codec: Fix buffer leak

If buffers were discarded because of wrong size or type a mmal buffer header
would be leaked each time.
Signed-off-by: default avatarJulian Scheel <julian@jusst.de>
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 3387d16d
...@@ -408,9 +408,8 @@ static int send_output_buffer(decoder_t *dec) ...@@ -408,9 +408,8 @@ static int send_output_buffer(decoder_t *dec)
picture = decoder_NewPicture(dec); picture = decoder_NewPicture(dec);
if (!picture) { if (!picture) {
msg_Warn(dec, "Failed to get new picture"); msg_Warn(dec, "Failed to get new picture");
mmal_buffer_header_release(buffer);
ret = -1; ret = -1;
goto out; goto err;
} }
p_sys = picture->p_sys; p_sys = picture->p_sys;
...@@ -426,7 +425,7 @@ static int send_output_buffer(decoder_t *dec) ...@@ -426,7 +425,7 @@ static int send_output_buffer(decoder_t *dec)
if (p_sys->buffer == NULL) { if (p_sys->buffer == NULL) {
msg_Err(dec, "Retrieved picture without opaque handle"); msg_Err(dec, "Retrieved picture without opaque handle");
ret = VLC_EGENERIC; ret = VLC_EGENERIC;
goto out; goto err;
} }
buffer->data = p_sys->buffer->data; buffer->data = p_sys->buffer->data;
} else { } else {
...@@ -434,7 +433,7 @@ static int send_output_buffer(decoder_t *dec) ...@@ -434,7 +433,7 @@ static int send_output_buffer(decoder_t *dec)
msg_Err(dec, "Retrieved picture with too small data block (%d < %d)", msg_Err(dec, "Retrieved picture with too small data block (%d < %d)",
buffer_size, sys->output->buffer_size); buffer_size, sys->output->buffer_size);
ret = VLC_EGENERIC; ret = VLC_EGENERIC;
goto out; goto err;
} }
buffer->data = picture->p[0].p_pixels; buffer->data = picture->p[0].p_pixels;
} }
...@@ -443,14 +442,18 @@ static int send_output_buffer(decoder_t *dec) ...@@ -443,14 +442,18 @@ static int send_output_buffer(decoder_t *dec)
if (status != MMAL_SUCCESS) { if (status != MMAL_SUCCESS) {
msg_Err(dec, "Failed to send buffer to output port (status=%"PRIx32" %s)", msg_Err(dec, "Failed to send buffer to output port (status=%"PRIx32" %s)",
status, mmal_status_to_string(status)); status, mmal_status_to_string(status));
mmal_buffer_header_release(buffer);
picture_Release(picture);
ret = -1; ret = -1;
goto out; goto err;
} }
out: out:
return ret; return ret;
err:
if (picture)
picture_Release(picture);
mmal_buffer_header_release(buffer);
return ret;
} }
static void fill_output_port(decoder_t *dec) static void fill_output_port(decoder_t *dec)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment