charon-nm: Fix building list of DNS/MDNS servers with libnm
authorTobias Brunner <tobias@strongswan.org>
Wed, 21 Feb 2018 10:53:55 +0000 (11:53 +0100)
committerTobias Brunner <tobias@strongswan.org>
Thu, 22 Feb 2018 08:05:48 +0000 (09:05 +0100)
g_variant_builder_add() creates a new GVariant using g_variant_new() and
then adds it to the builder.  Passing a GVariant probably adds the
pointer to the array, not the value.  I think an alternative fix would
be to use "@u" as type string for the g_variant_builder_add() call, then
the already allocated GVariant is adopted.

Fixes: 9a71b7219ca3 ("charon-nm: Port to libnm")

src/charon-nm/nm/nm_service.c

index 9beac39..c427331 100644 (file)
@@ -65,8 +65,7 @@ static GVariant* handler_to_variant(nm_handler_t *handler,
        enumerator = handler->create_enumerator(handler, type);
        while (enumerator->enumerate(enumerator, &chunk))
        {
-               g_variant_builder_add (&builder, "u",
-                                                          g_variant_new_uint32 (*(uint32_t*)chunk.ptr));
+               g_variant_builder_add (&builder, "u", *(uint32_t*)chunk.ptr);
        }
        enumerator->destroy(enumerator);