[FFmpeg-cvslog] libschroedinger: Check memory allocations

Vittorio Giovara git at videolan.org
Mon Feb 23 11:52:56 CET 2015


ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Sun Feb 22 19:49:06 2015 +0000| [e570f895cdccf2535a71fec1c607751ddb94fd5a] | committer: Vittorio Giovara

libschroedinger: Check memory allocations

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e570f895cdccf2535a71fec1c607751ddb94fd5a
---

 libavcodec/libschroedinger.c    |    2 ++
 libavcodec/libschroedingerdec.c |    2 ++
 libavcodec/libschroedingerenc.c |    4 ++++
 3 files changed, 8 insertions(+)

diff --git a/libavcodec/libschroedinger.c b/libavcodec/libschroedinger.c
index fc9188c..157433e 100644
--- a/libavcodec/libschroedinger.c
+++ b/libavcodec/libschroedinger.c
@@ -191,6 +191,8 @@ SchroFrame *ff_create_schro_frame(AVCodecContext *avctx,
     uv_height = y_height >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt));
 
     p_pic = av_mallocz(sizeof(AVPicture));
+    if (!p_pic)
+        return NULL;
     avpicture_alloc(p_pic, avctx->pix_fmt, y_width, y_height);
 
     p_frame         = schro_frame_new();
diff --git a/libavcodec/libschroedingerdec.c b/libavcodec/libschroedingerdec.c
index 0c5a3fb..c61aaef 100644
--- a/libavcodec/libschroedingerdec.c
+++ b/libavcodec/libschroedingerdec.c
@@ -271,6 +271,8 @@ static int libschroedinger_decode_frame(AVCodecContext *avctx,
                 /* Decoder needs a frame - create one and push it in. */
                 frame = ff_create_schro_frame(avctx,
                                               p_schro_params->frame_format);
+                if (!frame)
+                    return AVERROR(ENOMEM);
                 schro_decoder_add_output_picture(decoder, frame);
                 break;
 
diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c
index 3dc1481..b2c492b 100644
--- a/libavcodec/libschroedingerenc.c
+++ b/libavcodec/libschroedingerenc.c
@@ -283,6 +283,8 @@ static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     } else {
         /* Allocate frame data to schro input buffer. */
         SchroFrame *in_frame = libschroedinger_frame_from_data(avctx, frame);
+        if (!in_frame)
+            return AVERROR(ENOMEM);
         /* Load next frame. */
         schro_encoder_push_frame(encoder, in_frame);
     }
@@ -331,6 +333,8 @@ static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
             /* Create output frame. */
             p_frame_output = av_mallocz(sizeof(FFSchroEncodedFrame));
+            if (!p_frame_output)
+                return AVERROR(ENOMEM);
             /* Set output data. */
             p_frame_output->size     = p_schro_params->enc_buf_size;
             p_frame_output->p_encbuf = p_schro_params->enc_buf;



More information about the ffmpeg-cvslog mailing list