blob: 3583d5a8be88083afe87fea3e4f192f044236dbe [file] [log] [blame]
From a91ab7908955aa57f4c9ca52765d7cbe1cf5e71f Mon Sep 17 00:00:00 2001
From: Haihao Xiang <haihao.xiang@intel.com>
Date: Thu, 26 Mar 2020 13:46:56 +0800
Subject: [PATCH 2/2] glupload: fix segfault
Without this fix, it is possible that outbuf is not initialized, which
will result in segfault when call gst_buffer_replace (&outbuf, NULL). In
addition, the patch fixes potential memory leak in restart path.
The segfault can be reproduced by the pipeline below:
GST_GL_PLATFORM=egl \
gst-launch-1.0 videotestsrc ! msdkh265enc ! msdkh265dec ! \
'video/x-raw(memory:DMABuf)' ! glimagesink
https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/619
---
gst-libs/gst/gl/gstglupload.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gst-libs/gst/gl/gstglupload.c b/gst-libs/gst/gl/gstglupload.c
index 7d19f683a..2ef00a49b 100644
--- a/gst-libs/gst/gl/gstglupload.c
+++ b/gst-libs/gst/gl/gstglupload.c
@@ -1975,7 +1975,7 @@ gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer,
GstBuffer ** outbuf_ptr)
{
GstGLUploadReturn ret = GST_GL_UPLOAD_ERROR;
- GstBuffer *outbuf;
+ GstBuffer *outbuf = NULL;
gpointer last_impl = upload->priv->method_impl;
g_return_val_if_fail (GST_IS_GL_UPLOAD (upload), FALSE);
@@ -2016,6 +2016,8 @@ restart:
break;
}
}
+
+ gst_buffer_replace (&outbuf, NULL);
goto restart;
} else if (ret == GST_GL_UPLOAD_DONE || ret == GST_GL_UPLOAD_RECONFIGURE) {
if (last_impl != upload->priv->method_impl) {
@@ -2030,6 +2032,7 @@ restart:
/* we are done */
} else {
upload->priv->method_impl = NULL;
+ gst_buffer_replace (&outbuf, NULL);
NEXT_METHOD;
}
--
2.25.1