mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
rtmpsink: 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
4b93a7167f
commit
17da1ad409
1 changed files with 16 additions and 5 deletions
|
@ -162,15 +162,17 @@ gst_rtmp_sink_start (GstBaseSink * basesink)
|
|||
|
||||
sink->rtmp_uri = g_strdup (sink->uri);
|
||||
sink->rtmp = RTMP_Alloc ();
|
||||
|
||||
if (!sink->rtmp) {
|
||||
GST_ERROR_OBJECT (sink, "Could not allocate librtmp's RTMP context");
|
||||
goto error;
|
||||
}
|
||||
|
||||
RTMP_Init (sink->rtmp);
|
||||
if (!RTMP_SetupURL (sink->rtmp, sink->rtmp_uri)) {
|
||||
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
|
||||
("Failed to setup URL '%s'", sink->uri));
|
||||
RTMP_Free (sink->rtmp);
|
||||
sink->rtmp = NULL;
|
||||
g_free (sink->rtmp_uri);
|
||||
sink->rtmp_uri = NULL;
|
||||
return FALSE;
|
||||
goto error;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (sink, "Created RTMP object");
|
||||
|
@ -182,6 +184,15 @@ gst_rtmp_sink_start (GstBaseSink * basesink)
|
|||
sink->have_write_error = FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
if (sink->rtmp) {
|
||||
RTMP_Free (sink->rtmp);
|
||||
sink->rtmp = NULL;
|
||||
}
|
||||
g_free (sink->rtmp_uri);
|
||||
sink->rtmp_uri = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in a new issue