onnx: avoid leak on failure and cleanup

- Unmap buffer on Ort exception
- Avoid retrieving unused videometa

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5761>
This commit is contained in:
Daniel Morin 2023-12-04 20:47:31 -05:00 committed by GStreamer Marge Bot
parent 15e5866e51
commit d3ebaa316d

View file

@ -613,12 +613,6 @@ static gboolean
gst_onnx_inference_process (GstBaseTransform * trans, GstBuffer * buf) gst_onnx_inference_process (GstBaseTransform * trans, GstBuffer * buf)
{ {
GstMapInfo info; GstMapInfo info;
GstVideoMeta *vmeta = gst_buffer_get_video_meta (buf);
if (!vmeta) {
GST_WARNING_OBJECT (trans, "missing video meta");
return FALSE;
}
if (gst_buffer_map (buf, &info, GST_MAP_READ)) { if (gst_buffer_map (buf, &info, GST_MAP_READ)) {
GstOnnxInference *self = GST_ONNX_INFERENCE (trans); GstOnnxInference *self = GST_ONNX_INFERENCE (trans);
try { try {
@ -632,6 +626,7 @@ gst_onnx_inference_process (GstBaseTransform * trans, GstBuffer * buf)
} }
catch (Ort::Exception & ortex) { catch (Ort::Exception & ortex) {
GST_ERROR_OBJECT (self, "%s", ortex.what ()); GST_ERROR_OBJECT (self, "%s", ortex.what ());
gst_buffer_unmap (buf, &info);
return FALSE; return FALSE;
} }