From f2d021c519d09216a69c5f45275bf79f1a9f8bd6 Mon Sep 17 00:00:00 2001 From: "Joshua M. Doe" Date: Thu, 13 Aug 2020 14:50:51 -0400 Subject: [PATCH] matroxsrc: properly close resources if initialization fails --- sys/matrox/gstmatroxsrc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/matrox/gstmatroxsrc.c b/sys/matrox/gstmatroxsrc.c index ca0c822..fcf093e 100644 --- a/sys/matrox/gstmatroxsrc.c +++ b/sys/matrox/gstmatroxsrc.c @@ -497,7 +497,7 @@ gst_matroxsrc_start (GstBaseSrc * bsrc) if (ret == M_NULL) { GST_ELEMENT_ERROR (src, RESOURCE, FAILED, ("Failed to allocate a MIL system"), (NULL)); - return FALSE; + goto error; } /* create Digitizer */ @@ -511,7 +511,7 @@ gst_matroxsrc_start (GstBaseSrc * bsrc) if (ret == M_NULL) { GST_ELEMENT_ERROR (src, RESOURCE, FAILED, ("Failed to allocate a MIL digitizer"), (NULL)); - return FALSE; + goto error; } /* get format info and create caps */ @@ -597,7 +597,7 @@ gst_matroxsrc_start (GstBaseSrc * bsrc) } else { GST_ELEMENT_ERROR (src, STREAM, WRONG_TYPE, ("Unknown or unsupported bit depth (%d).", bpp), (NULL)); - return FALSE; + goto error; } } else if (n_bands == 3) { /* TODO: handle non-Solios color formats */ @@ -634,11 +634,16 @@ gst_matroxsrc_start (GstBaseSrc * bsrc) } else { GST_ELEMENT_ERROR (src, RESOURCE, FAILED, ("Failed to allocate a MIL buffer"), (NULL)); - return FALSE; + goto error; } } return TRUE; + +error: + gst_matroxsrc_reset (src); + + return FALSE; } static gboolean