[FFmpeg-devel] avformat/hlsenc: checking return value of avio_open_dyn_buf

Submitted by Steven Liu on Nov. 16, 2017, 2:53 a.m.

Details

Message ID 20171116025350.4542-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu Nov. 16, 2017, 2:53 a.m.
fix CID: 1421196

Signed-off-by: Steven Liu <lq@onvideo.cn>
---
 libavformat/hlsenc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Derek Buitenhuis Nov. 16, 2017, 1:19 p.m.
On 11/16/2017 2:53 AM, Steven Liu wrote:
> fix CID: 1421196
> 
> Signed-off-by: Steven Liu <lq@onvideo.cn>
> ---
>  libavformat/hlsenc.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Should be OK if it passes valgrind.

- Derek

Patch hide | download patch | download mbox

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e0cef8b879..54342cf288 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1678,7 +1678,11 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
                 range_length = avio_close_dyn_buf(oc->pb, &buffer);
                 avio_write(hls->out, buffer, range_length);
                 hls->init_range_length = range_length;
-                avio_open_dyn_buf(&oc->pb);
+                ret = avio_open_dyn_buf(&oc->pb);
+                if (ret < 0) {
+                    av_free(old_filename);
+                    return ret;
+                }
                 hls->packets_written = 0;
                 ff_format_io_close(s, &hls->out);
             } else {