diff options
author | Jens Georg <mail@jensge.org> | 2022-06-05 14:23:25 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-06-05 14:23:25 +0200 |
commit | 3fc3a1b4eba60cc0e475723e3efe08f4dcf02f6f (patch) | |
tree | 712205b812cdb29f431c28e05e27d718189ea4d1 | |
parent | 8b1e1d151bb59e3fa389d281030acaf24b25de78 (diff) | |
download | gupnp-3fc3a1b4eba60cc0e475723e3efe08f4dcf02f6f.tar.gz |
all: Coverity fixes
CID352971, CID352973, CID352974, CID352977, CID352980
Also sprinkle some coverity false-positive markers
-rw-r--r-- | examples/get-volume.c | 2 | ||||
-rw-r--r-- | libgupnp/gupnp-context.c | 6 | ||||
-rw-r--r-- | tests/test-acl.c | 3 | ||||
-rw-r--r-- | tests/test-context.c | 2 | ||||
-rw-r--r-- | tests/test-service-proxy.c | 10 |
5 files changed, 18 insertions, 5 deletions
diff --git a/examples/get-volume.c b/examples/get-volume.c index 9dbdac6..0413631 100644 --- a/examples/get-volume.c +++ b/examples/get-volume.c @@ -95,7 +95,7 @@ on_introspection (GObject *object, GAsyncResult *res, gpointer user_data) if (error != NULL) { g_critical ("%s", error->message); g_clear_error (&error); - } else { + } else if (out_values != NULL) { g_print ("Current volume: %s\n", g_value_get_string (out_values->data)); } diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c index d20e5cc..7b39ed5 100644 --- a/libgupnp/gupnp-context.c +++ b/libgupnp/gupnp-context.c @@ -1427,6 +1427,8 @@ gupnp_acl_server_handler (SoupServer *server, "root-device", &device, NULL); + // g_object_get will give us an additional reference here. + // drop that immediately if (device != NULL) { g_object_unref (device); } @@ -1466,6 +1468,10 @@ gupnp_acl_server_handler (SoupServer *server, handler); soup_server_pause_message (server, msg); + // Since we drop the additional reference above, coverity seems to think this is + // use-after-free, but the service is still holding a reference here. + + // coverity[pass_freed_arg] gupnp_acl_is_allowed_async ( priv->acl, device, diff --git a/tests/test-acl.c b/tests/test-acl.c index 12bc89c..275446a 100644 --- a/tests/test-acl.c +++ b/tests/test-acl.c @@ -272,7 +272,6 @@ test_gupnp_context_acl (ContextTestFixture *tf, gconstpointer user_data) acl->is_allowed = TRUE; gupnp_context_set_acl (tf->context, GUPNP_ACL (acl)); - g_object_unref (acl); g_assert (acl == (TestAcl *) gupnp_context_get_acl (tf->context)); @@ -397,6 +396,8 @@ test_gupnp_context_acl (ContextTestFixture *tf, gconstpointer user_data) g_object_unref (msg); g_free (request_uri); + + g_object_unref (acl); } int diff --git a/tests/test-context.c b/tests/test-context.c index e646d63..2dda7f7 100644 --- a/tests/test-context.c +++ b/tests/test-context.c @@ -155,6 +155,8 @@ request_range_and_compare (GMappedFile *file, &got_length); g_assert_cmpint (got_start, ==, want_start); g_assert_cmpint (got_end, ==, want_end); + + // coverity[leaked_storage] result = memcmp (g_mapped_file_get_contents (file) + want_start, g_bytes_get_data (h.body, NULL), want_length); diff --git a/tests/test-service-proxy.c b/tests/test-service-proxy.c index 240c154..f81b134 100644 --- a/tests/test-service-proxy.c +++ b/tests/test-service-proxy.c @@ -473,9 +473,9 @@ thread_func (gpointer data) gupnp_service_proxy_action_unref (action); if (d->expected_error.domain != 0) - g_error_matches (error, - d->expected_error.domain, - d->expected_error.code); + g_assert_error (error, + d->expected_error.domain, + d->expected_error.code); g_object_unref (gpd.p); g_object_unref (cp); @@ -515,6 +515,8 @@ test_sync_call (ProxyTestFixture *tf, gconstpointer user_data) // Spin the loop for a bit... g_timeout_add (500, (GSourceFunc) delayed_loop_quitter, tf->loop); g_main_loop_run (tf->loop); + + g_thread_unref (t); } gboolean @@ -554,6 +556,7 @@ test_cancel_sync_call (ProxyTestFixture *tf, gconstpointer user_data) // Spin the loop for a bit... g_timeout_add (500, (GSourceFunc) delayed_loop_quitter, tf->loop); g_main_loop_run (tf->loop); + g_thread_unref (t); } void @@ -632,6 +635,7 @@ test_finish_soap_error_sync (ProxyTestFixture *tf, gconstpointer user_data) // Spin the loop for a bit... g_timeout_add (500, (GSourceFunc) delayed_loop_quitter, tf->loop); g_main_loop_run (tf->loop); + g_thread_unref (t); } int |