Merge branch 'scan-build-fixes' into 'main'

Add some more assertions to help scan-build out

See merge request GNOME/glib!2646
This commit is contained in:
Simon McVittie 2022-05-10 16:30:18 +00:00
commit 816abcbb95
4 changed files with 16 additions and 5 deletions

View File

@ -874,7 +874,11 @@ client_free (Client *client)
name_ref (name);
if (name->owner && name->owner->client == client)
name_release_owner (name);
{
/* Help static analysers with the refcount at this point. */
g_assert (name->refcount >= 2);
name_release_owner (name);
}
name_unqueue_owner (name, client);

View File

@ -325,6 +325,7 @@ return_result (GTask *task)
{
GProxyAddressEnumeratorPrivate *priv = g_task_get_task_data (task);
GSocketAddress *result;
gboolean is_inet_socket_address;
if (strcmp ("direct", priv->proxy_type) == 0)
{
@ -356,12 +357,13 @@ return_result (GTask *task)
}
dest_protocol = g_uri_parse_scheme (priv->dest_uri);
if (!G_IS_INET_SOCKET_ADDRESS (priv->proxy_address))
is_inet_socket_address = G_IS_INET_SOCKET_ADDRESS (priv->proxy_address);
if (!is_inet_socket_address)
{
g_free (dest_hostname);
g_free (dest_protocol);
}
g_return_if_fail (G_IS_INET_SOCKET_ADDRESS (priv->proxy_address));
g_return_if_fail (is_inet_socket_address);
inetsaddr = G_INET_SOCKET_ADDRESS (priv->proxy_address);
inetaddr = g_inet_socket_address_get_address (inetsaddr);

View File

@ -1444,6 +1444,10 @@ g_static_resource_fini (GStaticResource *static_resource)
resource = g_atomic_pointer_get (&static_resource->resource);
if (resource)
{
/* There should be at least two references to the resource now: one for
* static_resource->resource, and one in the registered_resources list. */
g_assert (g_atomic_int_get (&resource->ref_count) >= 2);
g_atomic_pointer_set (&static_resource->resource, NULL);
g_resources_unregister_unlocked (resource);
g_resource_unref (resource);

View File

@ -800,12 +800,13 @@ g_variant_new_array (const GVariantType *child_type,
for (i = 0; i < n_children; i++)
{
if G_UNLIKELY (!g_variant_is_of_type (children[i], child_type))
gboolean is_of_child_type = g_variant_is_of_type (children[i], child_type);
if G_UNLIKELY (!is_of_child_type)
{
while (i != 0)
g_variant_unref (my_children[--i]);
g_free (my_children);
g_return_val_if_fail (g_variant_is_of_type (children[i], child_type), NULL);
g_return_val_if_fail (is_of_child_type, NULL);
}
my_children[i] = g_variant_ref_sink (children[i]);
trusted &= g_variant_is_trusted (children[i]);