diff mbox

[FFmpeg-devel] avcodec/omx: Do not pass negative value into av_malloc()

Message ID 20161229020246.20399-1-michael@niedermayer.cc
State Accepted
Commit bd83c295fc1b7f8001e5d134b912af86cd62c3f2
Headers show

Commit Message

Michael Niedermayer Dec. 29, 2016, 2:02 a.m. UTC
Fixes CID1396849

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/omx.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Jan. 8, 2017, 2:25 p.m. UTC | #1
On Thu, Dec 29, 2016 at 03:02:46AM +0100, Michael Niedermayer wrote:
> Fixes CID1396849
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/omx.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

applied

[...]
diff mbox

Patch

diff --git a/libavcodec/omx.c b/libavcodec/omx.c
index b5093f4941..16df50e456 100644
--- a/libavcodec/omx.c
+++ b/libavcodec/omx.c
@@ -761,7 +761,10 @@  static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             } else {
                 // If not, we need to allocate a new buffer with the right
                 // size and copy the input frame into it.
-                uint8_t *buf = av_malloc(av_image_get_buffer_size(avctx->pix_fmt, s->stride, s->plane_size, 1));
+                uint8_t *buf = NULL;
+                int image_buffer_size = av_image_get_buffer_size(avctx->pix_fmt, s->stride, s->plane_size, 1);
+                if (image_buffer_size >= 0)
+                    buf = av_malloc(image_buffer_size);
                 if (!buf) {
                     // Return the buffer to the queue so it's not lost
                     append_buffer(&s->input_mutex, &s->input_cond, &s->num_free_in_buffers, s->free_in_buffers, buffer);