summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatya Prakash Gupta <sp.gupta@samsung.com>2017-07-11 11:34:03 +0530
committerSebastian Dröge <sebastian@centricular.com>2017-07-25 11:27:24 +0300
commit70bda7ef53283115e3ee106caee7ae050a99d259 (patch)
tree11213e6a32c59e520903226681fa526cdc97ff35
parenta5ff06b71da295a3716a33816e9f2b5bdc73fb98 (diff)
downloadgst-libav-70bda7ef53283115e3ee106caee7ae050a99d259.tar.gz
avdemux/mux: Memory leak and possible crash in avio_alloc_context
https://bugzilla.gnome.org/show_bug.cgi?id=784735
-rw-r--r--ext/libav/gstavprotocol.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/libav/gstavprotocol.c b/ext/libav/gstavprotocol.c
index 5d01eaa..d106f9b 100644
--- a/ext/libav/gstavprotocol.c
+++ b/ext/libav/gstavprotocol.c
@@ -205,6 +205,9 @@ gst_ffmpegdata_close (AVIOContext * h)
{
GstProtocolInfo *info;
+ if (h == NULL)
+ return 0;
+
info = (GstProtocolInfo *) h->opaque;
if (info == NULL)
return 0;
@@ -265,6 +268,11 @@ gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context)
*context =
avio_alloc_context (buffer, buffer_size, flags, (void *) info,
gst_ffmpegdata_read, gst_ffmpegdata_write, gst_ffmpegdata_seek);
+ if (*context == NULL) {
+ GST_WARNING ("Failed to allocate memory");
+ av_free (buffer);
+ return -ENOMEM;
+ }
(*context)->seekable = AVIO_SEEKABLE_NORMAL;
if (!(flags & AVIO_FLAG_WRITE)) {
(*context)->buf_ptr = (*context)->buf_end;
@@ -318,6 +326,9 @@ gst_ffmpeg_pipe_close (AVIOContext * h)
{
GST_LOG ("Closing pipe");
+ if (h == NULL)
+ return 0;
+
h->opaque = NULL;
av_freep (&h->buffer);
av_free (h);
@@ -343,6 +354,11 @@ gst_ffmpeg_pipe_open (GstFFMpegPipe * ffpipe, int flags, AVIOContext ** context)
*context =
avio_alloc_context (buffer, buffer_size, 0, (void *) ffpipe,
gst_ffmpeg_pipe_read, NULL, NULL);
+ if (*context == NULL) {
+ GST_WARNING ("Failed to allocate memory");
+ av_free (buffer);
+ return -ENOMEM;
+ }
(*context)->seekable = 0;
(*context)->buf_ptr = (*context)->buf_end;