From 06d91520f9e585950b60d3f02c8aa24d870e8397 Mon Sep 17 00:00:00 2001 From: Jaeyun Date: Fri, 26 Jun 2020 11:04:20 +0900 Subject: [PATCH] [C-Api] fix mem leak 1. add g_free to release the memory when appending mem block in buffer. 2. free interator in switch api. Signed-off-by: Jaeyun --- api/capi/src/nnstreamer-capi-pipeline.c | 4 +++- ext/nnstreamer/tensor_converter/tensor_converter_flatbuf.cc | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/capi/src/nnstreamer-capi-pipeline.c b/api/capi/src/nnstreamer-capi-pipeline.c index 078162c..0aab246 100644 --- a/api/capi/src/nnstreamer-capi-pipeline.c +++ b/api/capi/src/nnstreamer-capi-pipeline.c @@ -1147,7 +1147,7 @@ ml_pipeline_src_input_data (ml_pipeline_src_h h, ml_tensors_data_h data, } mem = gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, - mem_data, mem_size, 0, mem_size, NULL, NULL); + mem_data, mem_size, 0, mem_size, mem_data, g_free); gst_buffer_append_memory (buffer, mem); /** @todo Verify that gst_buffer_append lists tensors/gstmem in the correct order */ @@ -1412,6 +1412,8 @@ ml_pipeline_switch_get_pad_list (ml_pipeline_switch_h h, char ***list) } } + gst_iterator_free (it); + /* There has been no error with that "while" loop. */ if (ret == ML_ERROR_NONE) { int i = 0; diff --git a/ext/nnstreamer/tensor_converter/tensor_converter_flatbuf.cc b/ext/nnstreamer/tensor_converter/tensor_converter_flatbuf.cc index 2883406..0a216f1 100644 --- a/ext/nnstreamer/tensor_converter/tensor_converter_flatbuf.cc +++ b/ext/nnstreamer/tensor_converter/tensor_converter_flatbuf.cc @@ -81,7 +81,7 @@ fbc_get_out_config (const GstCaps * in_cap, GstTensorsConfig * config) } /** @brief tensor converter plugin's NNStreamerExternalConverter callback - * @todo : Consider multi frames, return Bufferlist and + * @todo : Consider multi frames, return Bufferlist and * remove frame size and the number of frames */ static GstBuffer * @@ -134,7 +134,7 @@ fbc_convert (GstBuffer * in_buf, gsize * frame_size, guint * frames_in, mem_data = g_memdup (tensor_data->data (), mem_size); out_mem = gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, - mem_data, mem_size, 0, mem_size, NULL, NULL); + mem_data, mem_size, 0, mem_size, mem_data, g_free); gst_buffer_append_memory (out_buf, out_mem); } -- 2.7.4