mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/libwebpenc_animencoder: Fix memory leak of WebPData in libwebp_anim_encode_frame()
Signed-off-by: Andrey Volk <andywolk@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
2a44db59ca
commit
4e6debe1df
|
@ -70,14 +70,18 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
ret = WebPAnimEncoderAssemble(s->enc, &assembled_data);
|
ret = WebPAnimEncoderAssemble(s->enc, &assembled_data);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = ff_get_encode_buffer(avctx, pkt, assembled_data.size, 0);
|
ret = ff_get_encode_buffer(avctx, pkt, assembled_data.size, 0);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
|
WebPDataClear(&assembled_data);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
memcpy(pkt->data, assembled_data.bytes, assembled_data.size);
|
memcpy(pkt->data, assembled_data.bytes, assembled_data.size);
|
||||||
|
WebPDataClear(&assembled_data);
|
||||||
s->done = 1;
|
s->done = 1;
|
||||||
pkt->pts = pkt->dts = s->first_frame_pts;
|
pkt->pts = pkt->dts = s->first_frame_pts;
|
||||||
*got_packet = 1;
|
*got_packet = 1;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
WebPDataClear(&assembled_data);
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(s, AV_LOG_ERROR,
|
||||||
"WebPAnimEncoderAssemble() failed with error: %d\n",
|
"WebPAnimEncoderAssemble() failed with error: %d\n",
|
||||||
VP8_ENC_ERROR_OUT_OF_MEMORY);
|
VP8_ENC_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
Loading…
Reference in New Issue