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>
This commit is contained in:
Reimar Döffinger
2023-06-21 20:06:09 +02:00
parent dcff15692d
commit c0f867bf50
10 changed files with 56 additions and 15 deletions

View File

@@ -244,7 +244,7 @@ static int parse_file(AVIOContext *pb, FFDemuxSubtitlesQueue *subs)
ret = AVERROR_INVALIDDATA;
goto fail;
}
pkt = ff_subtitles_queue_insert(subs, content.str, content.len, 0);
pkt = ff_subtitles_queue_insert_bprint(subs, &content, 0);
if (!pkt) {
ret = AVERROR(ENOMEM);
goto fail;