Commit 1068e4d0 authored by Uri Lublin's avatar Uri Lublin
Browse files

spice-utils: allocate ctx after g_return_val_if_fail



Fix the following issue:
  Error: RESOURCE_LEAK
  src/spice-util.c:235: alloc_fn: Storage is returned
         from allocation function "whc_new".
  src/spice-util.c:235: var_assign: Assigning: "ctx" =
         storage returned from "whc_new(instance_obj, gobject)".
  src/spice-util.c:237: leaked_storage: Variable "ctx"
         going out of scope leaks the storage it points to.

  235|       WeakHandlerCtx *ctx = whc_new (instance_obj, gobject);
  236|
  237|->     g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0);
  238|       g_return_val_if_fail (detailed_signal != NULL, 0);
  239|       g_return_val_if_fail (c_handler != NULL, 0);
Signed-off-by: Uri Lublin's avatarUri Lublin <uril@redhat.com>
parent 35f69263
Pipeline #236267 passed with stage
in 2 minutes and 23 seconds
......@@ -231,7 +231,6 @@ gulong spice_g_signal_connect_object (gpointer instance,
GConnectFlags connect_flags)
{
GObject *instance_obj = G_OBJECT (instance);
WeakHandlerCtx *ctx = whc_new (instance_obj, gobject);
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0);
g_return_val_if_fail (detailed_signal != NULL, 0);
......@@ -240,6 +239,7 @@ gulong spice_g_signal_connect_object (gpointer instance,
g_return_val_if_fail (
(connect_flags & ~(G_CONNECT_AFTER|G_CONNECT_SWAPPED)) == 0, 0);
WeakHandlerCtx *ctx = whc_new (instance_obj, gobject);
if (connect_flags & G_CONNECT_SWAPPED)
ctx->closure = g_cclosure_new_object_swap (c_handler, gobject);
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment