]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libschroedingerenc.c
ffv1: Pass correct pointers to av_free()
[ffmpeg] / libavcodec / libschroedingerenc.c
index d53d846a43abd3287e624cf5fa1e61e5d96e7ffb..b2c492b990c64a047296de84dde06c66f4b299ed 100644 (file)
@@ -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);
     }
@@ -292,6 +294,7 @@ static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     /* Now check to see if we have any output from the encoder. */
     while (go) {
+        int err;
         SchroStateEnum state;
         state = schro_encoder_wait(encoder);
         switch (state) {
@@ -306,8 +309,12 @@ static int libschroedinger_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
              * be able to set the pts correctly. So we don't write data
              * to the frame output queue until we actually have a frame
              */
-            p_schro_params->enc_buf = av_realloc(p_schro_params->enc_buf,
-                                                 p_schro_params->enc_buf_size + enc_buf->length);
+            if ((err = av_reallocp(&p_schro_params->enc_buf,
+                                   p_schro_params->enc_buf_size +
+                                   enc_buf->length)) < 0) {
+                p_schro_params->enc_buf_size = 0;
+                return err;
+            }
 
             memcpy(p_schro_params->enc_buf + p_schro_params->enc_buf_size,
                    enc_buf->data, enc_buf->length);
@@ -326,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;