summaryrefslogtreecommitdiff
path: root/libavformat/realtextdec.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2023-06-21 20:06:09 +0200
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2023-07-29 16:05:29 +0200
commitc0f867bf503e79eba8ee52e1ac53322f88ec2929 (patch)
treed5c599f83135967be877d0a56daeca5b25df6398 /libavformat/realtextdec.c
parentdcff15692dff4c55827d640f1d5d07eb255a5a6a (diff)
libavformat: fix incorrect handling of incomplete AVBPrint.
Change some internal APIs a bit to make it harder to make such mistakes. In particular, have the read chunk functions return an error when the result is incomplete. This might be less flexible, but since there has been no use-case for that so far, avoiding coding mistakes seems better. Add a function to queue a AVBPrint directly (ff_subtitles_queue_insert_bprint). Also fixes a leak in lrcdec when ff_subtitles_queue_insert fails. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavformat/realtextdec.c')
-rw-r--r--libavformat/realtextdec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/realtextdec.c b/libavformat/realtextdec.c
index c281dec346..7992a5b7fc 100644
--- a/libavformat/realtextdec.c
+++ b/libavformat/realtextdec.c
@@ -80,6 +80,10 @@ static int realtext_read_header(AVFormatContext *s)
const int64_t pos = ff_text_pos(&tr) - (c != 0);
int n = ff_smil_extract_next_text_chunk(&tr, &buf, &c);
+ if (n < 0) {
+ res = n;
+ goto end;
+ }
if (n == 0)
break;
@@ -103,7 +107,7 @@ static int realtext_read_header(AVFormatContext *s)
/* if we just read a <time> tag, introduce a new event, otherwise merge
* with the previous one */
int merge = !av_strncasecmp(buf.str, "<time", 5) ? 0 : 1;
- sub = ff_subtitles_queue_insert(&rt->q, buf.str, buf.len, merge);
+ sub = ff_subtitles_queue_insert_bprint(&rt->q, &buf, merge);
if (!sub) {
res = AVERROR(ENOMEM);
goto end;