diff mbox series

[FFmpeg-devel,2/2] avformat/hlsenc: Only write something if there is something to write

Message ID AM7PR03MB666084FB1BF741ED00BBB60E8F939@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 96fe44e2e8e4c77e66cbb0834d340719741e964c
Headers show
Series [FFmpeg-devel,1/2] avformat/hlsenc: Remove nonsense memset | expand


Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 10, 2021, 1 p.m. UTC
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

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 557cf1bee3..cfd0c036d1 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -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;