avformat/hlsenc: Only write something if there is something to write

This is especially important in case avio_write() would be switched
to an unsigned type like size_t, then a potential error from avio_read()
(with negative return value) would no longer be handled gracefully by
avio_write().

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2021-11-09 22:21:37 +01:00
parent 7596b6530d
commit 96fe44e2e8
1 changed files with 1 additions and 1 deletions

View File

@ -2383,8 +2383,8 @@ static int64_t append_single_file(AVFormatContext *s, VariantStream *vs)
do {
read_byte = avio_read(vs->out, buf, BUFSIZE);
avio_write(vs->out_single_file, buf, read_byte);
if (read_byte > 0) {
avio_write(vs->out_single_file, buf, read_byte);
total_size += read_byte;
ret = total_size;
}