mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
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.
This commit is contained in:
parent
17da1ad409
commit
00587eb561
1 changed files with 15 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue