From cc6ca4ec61ee473c0c48ceccfacedb9d580c9fbf Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Thu, 29 Aug 2019 09:31:22 +0800 Subject: [PATCH] msdkvpp: free msdk surfaces to avoid memory leak --- sys/msdk/gstmsdkvpp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sys/msdk/gstmsdkvpp.c b/sys/msdk/gstmsdkvpp.c index ee0029ffb7..b50dfcdf99 100644 --- a/sys/msdk/gstmsdkvpp.c +++ b/sys/msdk/gstmsdkvpp.c @@ -718,6 +718,7 @@ gst_msdkvpp_transform (GstBaseTransform * trans, GstBuffer * inbuf, out_surface->surface = gst_msdk_get_surface_from_buffer (outbuf); } else { GST_ERROR ("Failed to get msdk outsurface!"); + free_msdk_surface (in_surface); return GST_FLOW_ERROR; } @@ -770,30 +771,29 @@ gst_msdkvpp_transform (GstBaseTransform * trans, GstBuffer * inbuf, } } while (status == MFX_ERR_MORE_SURFACE); - free_msdk_surface (in_surface); - return ret; + goto transform_end; vpp_error: GST_ERROR_OBJECT (thiz, "MSDK Failed to do VPP"); - free_msdk_surface (in_surface); - free_msdk_surface (out_surface); - return GST_FLOW_ERROR; + ret = GST_FLOW_ERROR; + goto transform_end; error_more_data: GST_WARNING_OBJECT (thiz, "MSDK Requries additional input for processing, " "Retruning FLOW_DROPPED since no output buffer was generated"); - free_msdk_surface (in_surface); - return GST_BASE_TRANSFORM_FLOW_DROPPED; + ret = GST_BASE_TRANSFORM_FLOW_DROPPED; + goto transform_end; error_push_buffer: - { - free_msdk_surface (in_surface); - free_msdk_surface (out_surface); - GST_DEBUG_OBJECT (thiz, "failed to push output buffer: %s", - gst_flow_get_name (ret)); - return ret; - } + GST_DEBUG_OBJECT (thiz, "failed to push output buffer: %s", + gst_flow_get_name (ret)); + +transform_end: + free_msdk_surface (in_surface); + free_msdk_surface (out_surface); + + return ret; } static void -- 2.34.1