X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flibschroedingerenc.c;h=b2c492b990c64a047296de84dde06c66f4b299ed;hb=338ed3ed33c412c2828446c4e2a76949161fec6a;hp=d53d846a43abd3287e624cf5fa1e61e5d96e7ffb;hpb=6f270da61b8c9a2dc71f48ae2a21e046d7f15b69;p=ffmpeg diff --git a/libavcodec/libschroedingerenc.c b/libavcodec/libschroedingerenc.c index d53d846a43a..b2c492b990c 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); } @@ -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;