[PATCH v3 2/5] winegstreamer: Move the conditional cleanup to the create error path.

Rémi Bernon rbernon at codeweavers.com
Tue Feb 22 03:40:59 CST 2022


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/winegstreamer/wg_transform.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c
index e4545774428..3ebf49b94aa 100644
--- a/dlls/winegstreamer/wg_transform.c
+++ b/dlls/winegstreamer/wg_transform.c
@@ -62,12 +62,10 @@ NTSTATUS wg_transform_destroy(void *args)
 {
     struct wg_transform *transform = args;
 
-    if (transform->my_sink)
-        g_object_unref(transform->my_sink);
-    if (transform->my_src)
-        g_object_unref(transform->my_src);
-
+    g_object_unref(transform->my_sink);
+    g_object_unref(transform->my_src);
     free(transform);
+
     return STATUS_SUCCESS;
 }
 
@@ -77,17 +75,15 @@ NTSTATUS wg_transform_create(void *args)
     struct wg_format output_format = *params->output_format;
     struct wg_format input_format = *params->input_format;
     GstCaps *src_caps = NULL, *sink_caps = NULL;
+    NTSTATUS status = STATUS_UNSUCCESSFUL;
     GstPadTemplate *template = NULL;
     struct wg_transform *transform;
-    NTSTATUS status;
 
     if (!init_gstreamer())
         return STATUS_UNSUCCESSFUL;
 
-    status = STATUS_NO_MEMORY;
-
     if (!(transform = calloc(1, sizeof(*transform))))
-        goto done;
+        return STATUS_NO_MEMORY;
 
     if (!(src_caps = wg_format_to_caps(&input_format)))
         goto done;
@@ -124,8 +120,11 @@ done:
     if (status)
     {
         GST_ERROR("Failed to create winegstreamer transform.");
-        if (transform)
-            wg_transform_destroy(transform);
+        if (transform->my_sink)
+            g_object_unref(transform->my_sink);
+        if (transform->my_src)
+            g_object_unref(transform->my_src);
+        free(transform);
     }
     else
     {
-- 
2.34.1




More information about the wine-devel mailing list