avcodec/roqaudioenc: Avoid redundant free of unallocated buffer

If allocating a buffer in RoQ DPCM encoder's init function failed,
the close function would be called manually; all this function does is
freeing said buffer, but given that it has not been allocated at all,
this is unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
pull/351/head
Andreas Rheinhardt 4 years ago
parent 771f91532c
commit 0b45ac5717
  1. 10
      libavcodec/roqaudioenc.c

@ -53,7 +53,6 @@ static av_cold int roq_dpcm_encode_close(AVCodecContext *avctx)
static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx) static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx)
{ {
ROQDPCMContext *context = avctx->priv_data; ROQDPCMContext *context = avctx->priv_data;
int ret;
if (avctx->channels > 2) { if (avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Audio must be mono or stereo\n"); av_log(avctx, AV_LOG_ERROR, "Audio must be mono or stereo\n");
@ -70,17 +69,12 @@ static av_cold int roq_dpcm_encode_init(AVCodecContext *avctx)
context->frame_buffer = av_malloc(8 * ROQ_FRAME_SIZE * avctx->channels * context->frame_buffer = av_malloc(8 * ROQ_FRAME_SIZE * avctx->channels *
sizeof(*context->frame_buffer)); sizeof(*context->frame_buffer));
if (!context->frame_buffer) { if (!context->frame_buffer)
ret = AVERROR(ENOMEM); return AVERROR(ENOMEM);
goto error;
}
context->lastSample[0] = context->lastSample[1] = 0; context->lastSample[0] = context->lastSample[1] = 0;
return 0; return 0;
error:
roq_dpcm_encode_close(avctx);
return ret;
} }
static unsigned char dpcm_predict(short *previous, short current) static unsigned char dpcm_predict(short *previous, short current)

Loading…
Cancel
Save