X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fsamidec.c;h=e32f238c629cac38de938716fd80287b940c27f2;hb=c490fc9536dcea7fdf1245a340bf075533610bc2;hp=262042475085968bc4d856edd79f23e9bd3c8436;hpb=7e3d6f10f08ae8ce9c6720fb7041fd739aef9143;p=ffmpeg diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c index 26204247508..e32f238c629 100644 --- a/libavcodec/samidec.c +++ b/libavcodec/samidec.c @@ -48,6 +48,9 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src) AVBPrint *dst_content = &sami->encoded_content; AVBPrint *dst_source = &sami->encoded_source; + if (!dupsrc) + return AVERROR(ENOMEM); + av_bprint_clear(&sami->encoded_content); av_bprint_clear(&sami->content); av_bprint_clear(&sami->encoded_source); @@ -135,9 +138,12 @@ static int sami_decode_frame(AVCodecContext *avctx, const char *ptr = avpkt->data; SAMIContext *sami = avctx->priv_data; - if (ptr && avpkt->size > 0 && !sami_paragraph_to_ass(avctx, ptr)) { + if (ptr && avpkt->size > 0) { + int ret = sami_paragraph_to_ass(avctx, ptr); + if (ret < 0) + return ret; // TODO: pass escaped sami->encoded_source.str as source - int ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, NULL, NULL); + ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, NULL, NULL); if (ret < 0) return ret; }