diff mbox

[FFmpeg-devel,7/8] avformat/hlsenc: check for null context to avoid uninitialized pointer access

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

Commit Message

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

Under error conditions, when the context is null, the application crashes
without this check.
---
 libavformat/hlsenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Liu Steven March 30, 2018, 6:32 a.m. UTC | #1
> On 30 Mar 2018, at 13:09, vdixit@akamai.com wrote:
> 
> From: Vishwanath Dixit <vdixit@akamai.com>
> 
> Under error conditions, when the context is null, the application crashes
> without this check.
> ---
> libavformat/hlsenc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 1dd196f..334720f 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -2318,7 +2318,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
>     }
> 
>     vs->packets_written++;
> -    ret = ff_write_chained(oc, stream_index, pkt, s, 0);
> +    if (oc->pb)
> +        ret = ff_write_chained(oc, stream_index, pkt, s, 0);
> 
>     return ret;
> }
> -- 
> 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 1dd196f..334720f 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2318,7 +2318,8 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     vs->packets_written++;
-    ret = ff_write_chained(oc, stream_index, pkt, s, 0);
+    if (oc->pb)
+        ret = ff_write_chained(oc, stream_index, pkt, s, 0);
 
     return ret;
 }