mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-24 09:58:54 +02:00
Merge branch 'backport-4005-scan-build-fixes-glib-2-80' into 'glib-2-80'
Backport !4005 “Fix various bugs found by scan-build“ to glib-2-80 See merge request GNOME/glib!4025
This commit is contained in:
@@ -1897,6 +1897,7 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection *connect
|
|||||||
|
|
||||||
if (out_serial == NULL)
|
if (out_serial == NULL)
|
||||||
out_serial = &serial;
|
out_serial = &serial;
|
||||||
|
*out_serial = 0;
|
||||||
|
|
||||||
if (timeout_msec == -1)
|
if (timeout_msec == -1)
|
||||||
timeout_msec = 25 * 1000;
|
timeout_msec = 25 * 1000;
|
||||||
@@ -5363,6 +5364,9 @@ g_dbus_connection_register_object (GDBusConnection *connection,
|
|||||||
out:
|
out:
|
||||||
CONNECTION_UNLOCK (connection);
|
CONNECTION_UNLOCK (connection);
|
||||||
|
|
||||||
|
if (ret == 0 && user_data_free_func != NULL)
|
||||||
|
user_data_free_func (user_data);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7019,6 +7023,9 @@ g_dbus_connection_register_subtree (GDBusConnection *connection,
|
|||||||
out:
|
out:
|
||||||
CONNECTION_UNLOCK (connection);
|
CONNECTION_UNLOCK (connection);
|
||||||
|
|
||||||
|
if (ret == 0 && user_data_free_func != NULL)
|
||||||
|
user_data_free_func (user_data);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1003,12 +1003,14 @@ test_object_registration (void)
|
|||||||
guint non_subtree_object_path_bar_reg_id;
|
guint non_subtree_object_path_bar_reg_id;
|
||||||
guint dyna_subtree_registration_id;
|
guint dyna_subtree_registration_id;
|
||||||
guint num_successful_registrations;
|
guint num_successful_registrations;
|
||||||
|
guint num_failed_registrations;
|
||||||
|
|
||||||
data.num_unregistered_calls = 0;
|
data.num_unregistered_calls = 0;
|
||||||
data.num_unregistered_subtree_calls = 0;
|
data.num_unregistered_subtree_calls = 0;
|
||||||
data.num_subtree_nodes = 0;
|
data.num_subtree_nodes = 0;
|
||||||
|
|
||||||
num_successful_registrations = 0;
|
num_successful_registrations = 0;
|
||||||
|
num_failed_registrations = 0;
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||||
@@ -1100,7 +1102,8 @@ test_object_registration (void)
|
|||||||
intern2_bar_reg_id = registration_id;
|
intern2_bar_reg_id = registration_id;
|
||||||
num_successful_registrations++;
|
num_successful_registrations++;
|
||||||
|
|
||||||
/* register at the same path/interface - this should fail */
|
/* register at the same path/interface - this should fail and result in an
|
||||||
|
* immediate unregistration (so the user_data isn’t leaked) */
|
||||||
registration_id = g_dbus_connection_register_object (c,
|
registration_id = g_dbus_connection_register_object (c,
|
||||||
"/foo/boss/interns/intern2",
|
"/foo/boss/interns/intern2",
|
||||||
(GDBusInterfaceInfo *) &bar_interface_info,
|
(GDBusInterfaceInfo *) &bar_interface_info,
|
||||||
@@ -1113,6 +1116,8 @@ test_object_registration (void)
|
|||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
g_assert (registration_id == 0);
|
g_assert (registration_id == 0);
|
||||||
|
g_assert_cmpint (data.num_unregistered_calls, ==, 1);
|
||||||
|
num_failed_registrations++;
|
||||||
|
|
||||||
/* register at different interface - shouldn't fail */
|
/* register at different interface - shouldn't fail */
|
||||||
registration_id = g_dbus_connection_register_object (c,
|
registration_id = g_dbus_connection_register_object (c,
|
||||||
@@ -1130,7 +1135,7 @@ test_object_registration (void)
|
|||||||
/* unregister it via the id */
|
/* unregister it via the id */
|
||||||
g_assert (g_dbus_connection_unregister_object (c, registration_id));
|
g_assert (g_dbus_connection_unregister_object (c, registration_id));
|
||||||
g_main_context_iteration (NULL, FALSE);
|
g_main_context_iteration (NULL, FALSE);
|
||||||
g_assert_cmpint (data.num_unregistered_calls, ==, 1);
|
g_assert_cmpint (data.num_unregistered_calls, ==, 2);
|
||||||
intern2_foo_reg_id = 0;
|
intern2_foo_reg_id = 0;
|
||||||
|
|
||||||
/* register it back */
|
/* register it back */
|
||||||
@@ -1181,12 +1186,12 @@ test_object_registration (void)
|
|||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
g_assert (registration_id == 0);
|
g_assert (registration_id == 0);
|
||||||
|
g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 1);
|
||||||
|
|
||||||
/* unregister it, then register it again */
|
/* unregister it, then register it again */
|
||||||
g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 0);
|
|
||||||
g_assert (g_dbus_connection_unregister_subtree (c, subtree_registration_id));
|
g_assert (g_dbus_connection_unregister_subtree (c, subtree_registration_id));
|
||||||
g_main_context_iteration (NULL, FALSE);
|
g_main_context_iteration (NULL, FALSE);
|
||||||
g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 1);
|
g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 2);
|
||||||
subtree_registration_id = g_dbus_connection_register_subtree (c,
|
subtree_registration_id = g_dbus_connection_register_subtree (c,
|
||||||
"/foo/boss/executives",
|
"/foo/boss/executives",
|
||||||
&subtree_vtable,
|
&subtree_vtable,
|
||||||
@@ -1382,10 +1387,10 @@ test_object_registration (void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check that unregistering the subtree handler works */
|
/* check that unregistering the subtree handler works */
|
||||||
g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 1);
|
g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 2);
|
||||||
g_assert (g_dbus_connection_unregister_subtree (c, subtree_registration_id));
|
g_assert (g_dbus_connection_unregister_subtree (c, subtree_registration_id));
|
||||||
g_main_context_iteration (NULL, FALSE);
|
g_main_context_iteration (NULL, FALSE);
|
||||||
g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 2);
|
g_assert_cmpint (data.num_unregistered_subtree_calls, ==, 3);
|
||||||
nodes = get_nodes_at (c, "/foo/boss/executives");
|
nodes = get_nodes_at (c, "/foo/boss/executives");
|
||||||
g_assert (nodes != NULL);
|
g_assert (nodes != NULL);
|
||||||
g_assert_cmpint (g_strv_length (nodes), ==, 1);
|
g_assert_cmpint (g_strv_length (nodes), ==, 1);
|
||||||
@@ -1405,7 +1410,7 @@ test_object_registration (void)
|
|||||||
g_assert (g_dbus_connection_unregister_object (c, non_subtree_object_path_foo_reg_id));
|
g_assert (g_dbus_connection_unregister_object (c, non_subtree_object_path_foo_reg_id));
|
||||||
|
|
||||||
g_main_context_iteration (NULL, FALSE);
|
g_main_context_iteration (NULL, FALSE);
|
||||||
g_assert_cmpint (data.num_unregistered_calls, ==, num_successful_registrations);
|
g_assert_cmpint (data.num_unregistered_calls, ==, num_successful_registrations + num_failed_registrations);
|
||||||
|
|
||||||
/* check that we no longer export any objects - TODO: it looks like there's a bug in
|
/* check that we no longer export any objects - TODO: it looks like there's a bug in
|
||||||
* libdbus-1 here: libdbus still reports the '/foo' object; so disable the test for now
|
* libdbus-1 here: libdbus still reports the '/foo' object; so disable the test for now
|
||||||
|
@@ -98,7 +98,7 @@ _xdg_glob_list_free (XdgGlobList *glob_list)
|
|||||||
|
|
||||||
static XdgGlobList *
|
static XdgGlobList *
|
||||||
_xdg_glob_list_append (XdgGlobList *glob_list,
|
_xdg_glob_list_append (XdgGlobList *glob_list,
|
||||||
void *data,
|
const char *data,
|
||||||
const char *mime_type,
|
const char *mime_type,
|
||||||
int weight,
|
int weight,
|
||||||
int case_sensitive)
|
int case_sensitive)
|
||||||
@@ -117,8 +117,8 @@ _xdg_glob_list_append (XdgGlobList *glob_list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_element = _xdg_glob_list_new ();
|
new_element = _xdg_glob_list_new ();
|
||||||
new_element->data = data;
|
new_element->data = strdup (data);
|
||||||
new_element->mime_type = mime_type;
|
new_element->mime_type = strdup (mime_type);
|
||||||
new_element->weight = weight;
|
new_element->weight = weight;
|
||||||
new_element->case_sensitive = case_sensitive;
|
new_element->case_sensitive = case_sensitive;
|
||||||
if (glob_list == NULL)
|
if (glob_list == NULL)
|
||||||
@@ -576,13 +576,13 @@ _xdg_glob_hash_append_glob (XdgGlobHash *glob_hash,
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case XDG_GLOB_LITERAL:
|
case XDG_GLOB_LITERAL:
|
||||||
glob_hash->literal_list = _xdg_glob_list_append (glob_hash->literal_list, strdup (glob), strdup (mime_type), weight, case_sensitive);
|
glob_hash->literal_list = _xdg_glob_list_append (glob_hash->literal_list, glob, mime_type, weight, case_sensitive);
|
||||||
break;
|
break;
|
||||||
case XDG_GLOB_SIMPLE:
|
case XDG_GLOB_SIMPLE:
|
||||||
glob_hash->simple_node = _xdg_glob_hash_insert_text (glob_hash->simple_node, glob + 1, mime_type, weight, case_sensitive);
|
glob_hash->simple_node = _xdg_glob_hash_insert_text (glob_hash->simple_node, glob + 1, mime_type, weight, case_sensitive);
|
||||||
break;
|
break;
|
||||||
case XDG_GLOB_FULL:
|
case XDG_GLOB_FULL:
|
||||||
glob_hash->full_list = _xdg_glob_list_append (glob_hash->full_list, strdup (glob), strdup (mime_type), weight, case_sensitive);
|
glob_hash->full_list = _xdg_glob_list_append (glob_hash->full_list, glob, mime_type, weight, case_sensitive);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -339,7 +339,7 @@ gi_function_invoker_new_for_address (void *addr,
|
|||||||
|
|
||||||
return ffi_prep_cif (&(invoker->cif), FFI_DEFAULT_ABI, n_args,
|
return ffi_prep_cif (&(invoker->cif), FFI_DEFAULT_ABI, n_args,
|
||||||
gi_callable_info_get_ffi_return_type (info),
|
gi_callable_info_get_ffi_return_type (info),
|
||||||
atypes) == FFI_OK;
|
g_steal_pointer (&atypes)) == FFI_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -409,10 +409,15 @@ gi_callable_info_create_closure (GICallableInfo *callable_info,
|
|||||||
status = ffi_prep_cif (cif, FFI_DEFAULT_ABI, n_args,
|
status = ffi_prep_cif (cif, FFI_DEFAULT_ABI, n_args,
|
||||||
gi_callable_info_get_ffi_return_type (callable_info),
|
gi_callable_info_get_ffi_return_type (callable_info),
|
||||||
atypes);
|
atypes);
|
||||||
|
|
||||||
|
/* Explicitly store atypes to satisfy static analysers, which can’t see inside
|
||||||
|
* ffi_prep_cif(), and hence assume that it’s leaked. */
|
||||||
|
cif->arg_types = g_steal_pointer (&atypes);
|
||||||
|
|
||||||
if (status != FFI_OK)
|
if (status != FFI_OK)
|
||||||
{
|
{
|
||||||
g_warning ("ffi_prep_cif failed: %d", status);
|
g_warning ("ffi_prep_cif failed: %d", status);
|
||||||
ffi_closure_free (closure);
|
gi_callable_info_destroy_closure (callable_info, &closure->ffi_closure);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,7 +425,7 @@ gi_callable_info_create_closure (GICallableInfo *callable_info,
|
|||||||
if (status != FFI_OK)
|
if (status != FFI_OK)
|
||||||
{
|
{
|
||||||
g_warning ("ffi_prep_closure failed: %d", status);
|
g_warning ("ffi_prep_closure failed: %d", status);
|
||||||
ffi_closure_free (closure);
|
gi_callable_info_destroy_closure (callable_info, &closure->ffi_closure);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1811,6 +1811,8 @@ do_posix_spawn (const gchar * const *argv,
|
|||||||
goto out_close_fds;
|
goto out_close_fds;
|
||||||
|
|
||||||
duped_source_fds = g_new (gint, n_fds);
|
duped_source_fds = g_new (gint, n_fds);
|
||||||
|
for (i = 0; i < n_fds; i++)
|
||||||
|
duped_source_fds[i] = -1; /* initialise in case dupfd_cloexec() fails below */
|
||||||
for (i = 0; i < n_fds; i++)
|
for (i = 0; i < n_fds; i++)
|
||||||
{
|
{
|
||||||
duped_source_fds[i] = dupfd_cloexec (source_fds[i], max_target_fd + 1);
|
duped_source_fds[i] = dupfd_cloexec (source_fds[i], max_target_fd + 1);
|
||||||
|
@@ -762,7 +762,8 @@ gvs_variable_sized_array_get_child (GVariantSerialised value,
|
|||||||
* Don’t bother checking if the highest known-good offset is lower than the
|
* Don’t bother checking if the highest known-good offset is lower than the
|
||||||
* highest checked offset, as that means there’s an invalid element at that
|
* highest checked offset, as that means there’s an invalid element at that
|
||||||
* index, so there’s no need to check further. */
|
* index, so there’s no need to check further. */
|
||||||
if (index_ > value.checked_offsets_up_to &&
|
if (offsets.array != NULL &&
|
||||||
|
index_ > value.checked_offsets_up_to &&
|
||||||
value.ordered_offsets_up_to == value.checked_offsets_up_to)
|
value.ordered_offsets_up_to == value.checked_offsets_up_to)
|
||||||
{
|
{
|
||||||
switch (offsets.offset_size)
|
switch (offsets.offset_size)
|
||||||
|
@@ -1018,7 +1018,7 @@ param_value_array_validate (GParamSpec *pspec,
|
|||||||
guint changed = 0;
|
guint changed = 0;
|
||||||
|
|
||||||
if (!value->data[0].v_pointer && aspec->fixed_n_elements)
|
if (!value->data[0].v_pointer && aspec->fixed_n_elements)
|
||||||
value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
|
value_array = value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
|
||||||
|
|
||||||
if (value->data[0].v_pointer)
|
if (value->data[0].v_pointer)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user