summaryrefslogtreecommitdiff
path: root/ext/rtmp
diff options
context:
space:
mode:
authorReynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>2015-12-29 14:35:14 -0800
committerReynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>2015-12-30 17:22:54 -0800
commit00587eb561c243745defc442f9b139e80a50ba92 (patch)
treeafc2e95a4abf67606021153f7e8185eff1d8983f /ext/rtmp
parent17da1ad409f7f03dc9962c053536489f46ce1967 (diff)
downloadgstreamer-plugins-bad-00587eb561c243745defc442f9b139e80a50ba92.tar.gz
rtmpsrc: check for failed RTMP context alloc
Avoids an unlikely crash. Arguably, if allocation fails we have no chance of recovering but nonetheless, RTMP_Alloc can fail and librtmp's RTMP_init() (called next) assumes a non-NULL pointer is passed without checking. Additionally, unify exit path on error.
Diffstat (limited to 'ext/rtmp')
-rw-r--r--ext/rtmp/gstrtmpsrc.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/ext/rtmp/gstrtmpsrc.c b/ext/rtmp/gstrtmpsrc.c
index 46918e755..02cbec1d1 100644
--- a/ext/rtmp/gstrtmpsrc.c
+++ b/ext/rtmp/gstrtmpsrc.c
@@ -575,13 +575,17 @@ gst_rtmp_src_start (GstBaseSrc * basesrc)
src->discont = TRUE;
src->rtmp = RTMP_Alloc ();
+
+ if (!src->rtmp) {
+ GST_ERROR_OBJECT (src, "Could not allocate librtmp's RTMP context");
+ goto error;
+ }
+
RTMP_Init (src->rtmp);
if (!RTMP_SetupURL (src->rtmp, src->uri)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Failed to setup URL '%s'", src->uri));
- RTMP_Free (src->rtmp);
- src->rtmp = NULL;
- return FALSE;
+ goto error;
}
src->seekable = !(src->rtmp->Link.lFlags & RTMP_LF_LIVE);
GST_INFO_OBJECT (src, "seekable %d", src->seekable);
@@ -591,13 +595,18 @@ gst_rtmp_src_start (GstBaseSrc * basesrc)
if (!RTMP_Connect (src->rtmp, NULL)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Could not connect to RTMP stream \"%s\" for reading", src->uri));
- RTMP_Free (src->rtmp);
- src->rtmp = NULL;
- return FALSE;
+ goto error;
}
}
return TRUE;
+
+error:
+ if (src->rtmp) {
+ RTMP_Free (src->rtmp);
+ src->rtmp = NULL;
+ }
+ return FALSE;
}
#undef STR2AVAL