diff options
author | Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com> | 2015-12-29 14:16:58 -0800 |
---|---|---|
committer | Reynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com> | 2015-12-30 17:22:42 -0800 |
commit | 17da1ad409f7f03dc9962c053536489f46ce1967 (patch) | |
tree | eb4eaa948c4fd8acad2defeb3337c742c9bc0e8c /ext | |
parent | 4b93a7167ff1fa82c9d4f23c99d34f4a9df8e629 (diff) | |
download | gstreamer-plugins-bad-17da1ad409f7f03dc9962c053536489f46ce1967.tar.gz |
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.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/rtmp/gstrtmpsink.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/ext/rtmp/gstrtmpsink.c b/ext/rtmp/gstrtmpsink.c index 095c6ef3d..462ac4d06 100644 --- a/ext/rtmp/gstrtmpsink.c +++ b/ext/rtmp/gstrtmpsink.c @@ -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 |