From 7dbf68a232fa76f43181053ce04f7ec2f75cecd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 23 Sep 2011 17:02:49 +0200 Subject: [PATCH] omxaudioenc: Add a check to prevent a zero-sized OMX buffer --- omx/gstomxaudioenc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index eae62e37bc..f36f3825d3 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -807,6 +807,9 @@ gst_omx_audio_enc_handle_frame (GstBaseAudioEncoder * encoder, g_assert (acq_ret == GST_OMX_ACQUIRE_BUFFER_OK && buf != NULL); + if (buf->omx_buf->nAllocLen - buf->omx_buf->nOffset <= 0) + goto full_buffer; + /* Copy the buffer content in chunks of size as requested * by the port */ buf->omx_buf->nFilledLen = @@ -841,6 +844,14 @@ gst_omx_audio_enc_handle_frame (GstBaseAudioEncoder * encoder, return GST_FLOW_OK; +full_buffer: + { + GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL), + ("Got OpenMAX buffer with no free space (%p, %u/%u)", buf, + buf->omx_buf->nOffset, buf->omx_buf->nAllocLen)); + gst_omx_port_release_buffer (self->in_port, buf); + return GST_FLOW_ERROR; + } component_error: { GST_ELEMENT_ERROR (self, LIBRARY, FAILED, (NULL),