aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/srtdec.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/srtdec.c
parentdcff15692dff4c55827d640f1d5d07eb255a5a6a (diff)
downloadffmpeg-c0f867bf503e79eba8ee52e1ac53322f88ec2929.tar.gz
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/srtdec.c')
-rw-r--r--libavformat/srtdec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c
index bf02450555..635c1550b9 100644
--- a/libavformat/srtdec.c
+++ b/libavformat/srtdec.c
@@ -97,12 +97,14 @@ static int add_event(FFDemuxSubtitlesQueue *q, AVBPrint *buf, char *line_cache,
if (append_cache && line_cache[0])
av_bprintf(buf, "%s\n", line_cache);
line_cache[0] = 0;
+ if (!av_bprint_is_complete(buf))
+ return AVERROR(ENOMEM);
while (buf->len > 0 && buf->str[buf->len - 1] == '\n')
buf->str[--buf->len] = 0;
if (buf->len) {
- AVPacket *sub = ff_subtitles_queue_insert(q, buf->str, buf->len, 0);
+ AVPacket *sub = ff_subtitles_queue_insert_bprint(q, buf, 0);
if (!sub)
return AVERROR(ENOMEM);
av_bprint_clear(buf);