aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/assenc.c
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2023-03-08 15:33:24 -0600
committerrcombs <rcombs@rcombs.me>2023-03-21 14:24:31 -0400
commitc0d9327a63db2b7f15783b59488a480e5d9d6d56 (patch)
treeab4325e949701a5274f9969cc330f62b34f65fb1 /libavcodec/assenc.c
parentb68a6ba469daae89fcf651d5ec44cc1821a014e4 (diff)
downloadffmpeg-c0d9327a63db2b7f15783b59488a480e5d9d6d56.tar.gz
lavc/ass: error if not passed exactly 1 rect
This never produced valid output.
Diffstat (limited to 'libavcodec/assenc.c')
-rw-r--r--libavcodec/assenc.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/libavcodec/assenc.c b/libavcodec/assenc.c
index db6fd25dd7..e548b9fd3b 100644
--- a/libavcodec/assenc.c
+++ b/libavcodec/assenc.c
@@ -45,27 +45,26 @@ static int ass_encode_frame(AVCodecContext *avctx,
unsigned char *buf, int bufsize,
const AVSubtitle *sub)
{
- int i, len, total_len = 0;
+ int len;
- for (i=0; i<sub->num_rects; i++) {
- const char *ass = sub->rects[i]->ass;
-
- if (sub->rects[i]->type != SUBTITLE_ASS) {
- av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
- return AVERROR(EINVAL);
- }
+ if (sub->num_rects != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Only one rect per AVSubtitle is supported in ASS.\n");
+ return AVERROR_INVALIDDATA;
+ }
- len = av_strlcpy(buf+total_len, ass, bufsize-total_len);
+ if (sub->rects[0]->type != SUBTITLE_ASS) {
+ av_log(avctx, AV_LOG_ERROR, "Only SUBTITLE_ASS type supported.\n");
+ return AVERROR(EINVAL);
+ }
- if (len > bufsize-total_len-1) {
- av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
- return AVERROR_BUFFER_TOO_SMALL;
- }
+ len = av_strlcpy(buf, sub->rects[0]->ass, bufsize);
- total_len += len;
+ if (len > bufsize - 1) {
+ av_log(avctx, AV_LOG_ERROR, "Buffer too small for ASS event.\n");
+ return AVERROR_BUFFER_TOO_SMALL;
}
- return total_len;
+ return len;
}
#if CONFIG_SSA_ENCODER