summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha.yang@navercorp.com>2018-08-31 14:55:05 +0900
committerSebastian Dröge <sebastian@centricular.com>2018-08-31 10:03:35 +0300
commit3bd3cc7bb0913c423319c91ae20e19286d01e80a (patch)
tree2c9a6fc8076c1d56f34728ee28d8abf66f40ab6b
parent7d7937889538a23d08994cc22d766cce89d2a198 (diff)
rtmpsink: Fix leak on connection failure
Although RTMP_ConnectStream() was failed, librtmp's internal memory is not freed by RTMP_ConnectStream(), so RTMP_Close() should be called before RTMP_Free() https://bugzilla.gnome.org/show_bug.cgi?id=797058
-rw-r--r--ext/rtmp/gstrtmpsink.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/ext/rtmp/gstrtmpsink.c b/ext/rtmp/gstrtmpsink.c
index 47c3d6088..aed5ab412 100644
--- a/ext/rtmp/gstrtmpsink.c
+++ b/ext/rtmp/gstrtmpsink.c
@@ -239,17 +239,14 @@ gst_rtmp_sink_render (GstBaseSink * bsink, GstBuffer * buf)
if (sink->first) {
/* open the connection */
if (!RTMP_IsConnected (sink->rtmp)) {
- if (!RTMP_Connect (sink->rtmp, NULL)
- || !RTMP_ConnectStream (sink->rtmp, 0)) {
- GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
- ("Could not connect to RTMP stream \"%s\" for writing", sink->uri));
- RTMP_Free (sink->rtmp);
- sink->rtmp = NULL;
- g_free (sink->rtmp_uri);
- sink->rtmp_uri = NULL;
- sink->have_write_error = TRUE;
- return GST_FLOW_ERROR;
+ if (!RTMP_Connect (sink->rtmp, NULL))
+ goto connection_failed;
+
+ if (!RTMP_ConnectStream (sink->rtmp, 0)) {
+ RTMP_Close (sink->rtmp);
+ goto connection_failed;
}
+
GST_DEBUG_OBJECT (sink, "Opened connection to %s", sink->rtmp_uri);
}
@@ -290,6 +287,19 @@ write_failed:
sink->have_write_error = TRUE;
return GST_FLOW_ERROR;
}
+
+connection_failed:
+ {
+ GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
+ ("Could not connect to RTMP stream \"%s\" for writing", sink->uri));
+ RTMP_Free (sink->rtmp);
+ sink->rtmp = NULL;
+ g_free (sink->rtmp_uri);
+ sink->rtmp_uri = NULL;
+ sink->have_write_error = TRUE;
+
+ return GST_FLOW_ERROR;
+ }
}
/*