You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/decode: Check size before opening iconv
Avoids closing iconv when the size check fails. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
@@ -884,18 +884,17 @@ static int recode_subtitle(AVCodecContext *avctx,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#if CONFIG_ICONV
|
#if CONFIG_ICONV
|
||||||
cd = iconv_open("UTF-8", avctx->sub_charenc);
|
|
||||||
av_assert0(cd != (iconv_t)-1);
|
|
||||||
|
|
||||||
inb = inpkt->data;
|
inb = inpkt->data;
|
||||||
inl = inpkt->size;
|
inl = inpkt->size;
|
||||||
|
|
||||||
if (inl >= INT_MAX / UTF8_MAX_BYTES - AV_INPUT_BUFFER_PADDING_SIZE) {
|
if (inl >= INT_MAX / UTF8_MAX_BYTES - AV_INPUT_BUFFER_PADDING_SIZE) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Subtitles packet is too big for recoding\n");
|
av_log(avctx, AV_LOG_ERROR, "Subtitles packet is too big for recoding\n");
|
||||||
ret = AVERROR(ENOMEM);
|
return AVERROR(ERANGE);
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cd = iconv_open("UTF-8", avctx->sub_charenc);
|
||||||
|
av_assert0(cd != (iconv_t)-1);
|
||||||
|
|
||||||
ret = av_new_packet(&tmp, inl * UTF8_MAX_BYTES);
|
ret = av_new_packet(&tmp, inl * UTF8_MAX_BYTES);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
goto end;
|
||||||
|
Reference in New Issue
Block a user