diff mbox series

[FFmpeg-devel,5/6] avformat/hlsenc: use proper error codes

Message ID 1592839474-2804-5-git-send-email-lance.lmwang@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/6] avutil/opt: check return value of av_bprint_finalize()
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Limin Wang June 22, 2020, 3:24 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/hlsenc.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 71fa3db..f7a4f30 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -370,6 +370,7 @@  static int replace_str_data_in_filename(char **s, const char *filename, char pla
     int addchar_count;
     int found_count = 0;
     AVBPrint buf;
+    int ret;
 
     av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
 
@@ -395,10 +396,10 @@  static int replace_str_data_in_filename(char **s, const char *filename, char pla
     }
     if (!av_bprint_is_complete(&buf)) {
         av_bprint_finalize(&buf, NULL);
-        return -1;
+        return AVERROR(ENOMEM);
     }
-    if (av_bprint_finalize(&buf, &new_filename) < 0 || !new_filename)
-        return -1;
+    if ((ret = av_bprint_finalize(&buf, &new_filename)) < 0 || !new_filename)
+        return ret;
     *s = new_filename;
     return found_count;
 }
@@ -411,6 +412,7 @@  static int replace_int_data_in_filename(char **s, const char *filename, char pla
     int nd, addchar_count;
     int found_count = 0;
     AVBPrint buf;
+    int ret;
 
     av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
 
@@ -444,10 +446,10 @@  static int replace_int_data_in_filename(char **s, const char *filename, char pla
     }
     if (!av_bprint_is_complete(&buf)) {
         av_bprint_finalize(&buf, NULL);
-        return -1;
+        return AVERROR(ENOMEM);
     }
-    if (av_bprint_finalize(&buf, &new_filename) < 0 || !new_filename)
-        return -1;
+    if ((ret = av_bprint_finalize(&buf, &new_filename)) < 0 || !new_filename)
+        return ret;
     *s = new_filename;
     return found_count;
 }