Skip to content

Commit

Permalink
Fix memory leak in dual sink pad mode
Browse files Browse the repository at this point in the history
This memory leak happened in the model pad buffer
processing only when both model and bypass sink
pads were used.
  • Loading branch information
rrcarlosrodriguez committed Jul 22, 2020
1 parent 071f712 commit 0be696a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gst-libs/gst/r2inference/gstvideoinference.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ gst_video_inference_process_model (GstVideoInference * self, GstBuffer * buffer,
GST_ELEMENT_ERROR (self, STREAM, FAILED,
("Subclass didn't implement post-process"), (NULL));
ret = GST_FLOW_ERROR;
goto buffer_free;
goto out;
}

buffer_model = gst_buffer_make_writable (buffer);
Expand Down Expand Up @@ -939,7 +939,7 @@ gst_video_inference_process_model (GstVideoInference * self, GstBuffer * buffer,
if (!video_inference_prepare_postprocess (klass->inference_meta_info,
buffer_model, info_model, meta_model)) {
ret = GST_FLOW_ERROR;
goto prediction_free;
goto buffer_free;
}

/* Subclass Processing */
Expand All @@ -949,7 +949,7 @@ gst_video_inference_process_model (GstVideoInference * self, GstBuffer * buffer,
GST_ELEMENT_ERROR (self, STREAM, FAILED, ("Subclass failed at preprocess"),
(NULL));
ret = GST_FLOW_ERROR;
goto prediction_free;
goto buffer_free;
}

/* Check if bypass pad was requested, if not, forward buffer */
Expand All @@ -976,13 +976,12 @@ gst_video_inference_process_model (GstVideoInference * self, GstBuffer * buffer,
ret = gst_video_inference_forward_buffer (self, gst_buffer_ref (buffer_model),
priv->src_model);

prediction_free:
g_free (prediction_data);

buffer_free:
gst_buffer_unref (buffer_model);

out:
g_free (prediction_data);

return ret;
}

Expand Down

0 comments on commit 0be696a

Please sign in to comment.