diff --git a/ext/rtmp/gstrtmpsrc.c b/ext/rtmp/gstrtmpsrc.c index 46918e755f..02cbec1d1c 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