diff --git a/libavcodec/omx.c b/libavcodec/omx.c index b5093f49418720d7a5f76d0f4abf4c1b9000f655..16df50e456736c811d987e8e44d11622e0c0b5e2 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);