diff mbox

[FFmpeg-devel,6/8] avformat/hlsenc: handling errors in hlsenc_io_open and hlsenc_io_close

Message ID 1522386532-16486-1-git-send-email-vdixit@akamai.com
State New
Headers show

Commit Message

Dixit, Vishwanath March 30, 2018, 5:08 a.m. UTC
From: Vishwanath Dixit <vdixit@akamai.com>

---
 libavformat/hlsenc.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Steven Liu March 30, 2018, 6:32 a.m. UTC | #1
> On 30 Mar 2018, at 13:08, vdixit@akamai.com wrote:
> 
> From: Vishwanath Dixit <vdixit@akamai.com>
> 
> ---
> libavformat/hlsenc.c | 4 ++++
> 1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 2a54b43..1dd196f 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -272,6 +272,8 @@ static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
>         URLContext *http_url_context = ffio_geturlcontext(*pb);
>         av_assert0(http_url_context);
>         err = ff_http_do_new_request(http_url_context, filename);
> +        if (err < 0)
> +            ff_format_io_close(s, pb);
> #endif
>     }
>     return err;
> @@ -280,6 +282,8 @@ static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
> static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) {
>     HLSContext *hls = s->priv_data;
>     int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
> +    if (!*pb)
> +        return;
>     if (!http_base_proto || !hls->http_persistent || hls->key_info_file || hls->encrypt) {
>         ff_format_io_close(s, pb);
> #if CONFIG_HTTP_PROTOCOL
> -- 
> 1.9.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

LGTM

Thanks
Steven
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 2a54b43..1dd196f 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -272,6 +272,8 @@  static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
         URLContext *http_url_context = ffio_geturlcontext(*pb);
         av_assert0(http_url_context);
         err = ff_http_do_new_request(http_url_context, filename);
+        if (err < 0)
+            ff_format_io_close(s, pb);
 #endif
     }
     return err;
@@ -280,6 +282,8 @@  static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
 static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename) {
     HLSContext *hls = s->priv_data;
     int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
+    if (!*pb)
+        return;
     if (!http_base_proto || !hls->http_persistent || hls->key_info_file || hls->encrypt) {
         ff_format_io_close(s, pb);
 #if CONFIG_HTTP_PROTOCOL