Skip to content

Commit

Permalink
[C-API] Bugfix for ml_pipeline_element_get_handle
Browse files Browse the repository at this point in the history
Need to ref element obtained by iterate_element() and unref it in cleanup_node() for common_elem

- common_elem by ml_pipeline_element_get_handle() need to unref in cleaunup_node() because g_hash_table_lookup assign new memory.
  but normal operation, unref is not necessary, so add ref in iterate_element()
- Now, the element's finalize function is called after ml_pipeline_element_get_handle()

Signed-off-by: hyunil park <[email protected]>
  • Loading branch information
songgot authored and jaeyun-jung committed Aug 29, 2023
1 parent 43eafdb commit 9e65380
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion c/src/ml-api-inference-pipeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ cleanup_node (gpointer data)
if (e->sink)
gst_object_unref (e->sink);

gst_object_unref (e->element);

_ml_tensors_info_free (&e->tensors_info);

g_mutex_unlock (&e->lock);
Expand Down Expand Up @@ -915,7 +917,8 @@ iterate_element (ml_pipeline * pipe_h, GstElement * pipeline,
if (element_type != ML_PIPELINE_ELEMENT_UNKNOWN) {
ml_pipeline_element *e;

e = construct_element (elem, pipe_h, name, element_type);
e = construct_element (gst_object_ref (elem), pipe_h, name,
element_type);
if (e != NULL) {
if (g_str_equal (element_name, "tensor_if"))
process_tensor_if_option (e);
Expand All @@ -925,6 +928,7 @@ iterate_element (ml_pipeline * pipe_h, GstElement * pipeline,
g_hash_table_insert (pipe_h->namednodes, g_strdup (name), e);
} else {
/* allocation failure */
gst_object_unref (elem);
_ml_error_report_continue
("Cannot allocate memory with construct_element().");
status = ML_ERROR_OUT_OF_MEMORY;
Expand Down

0 comments on commit 9e65380

Please sign in to comment.