2a9ddc630341789c629c17c17565f5a7a7db8a8e.diff 2.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
In Ubuntu 19.10, we use GCC 9.2.1 and glib was failing to compile with
the following message:

  CC       libgio_2_0_la-gdbusauth.lo
gdbusauth.c: In function '_g_dbus_auth_run_server':
gdbusauth.c:1302:11: error: '%s' directive argument is null [-Werror=format-overflow=]
 1302 |           debug_print ("SERVER: WaitingForBegin, read '%s'", line);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

So we apply this MR:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/626
corresponding to this commit:
https://gitlab.gnome.org/GNOME/glib/-/commit/2a9ddc630341789c629c17c17565f5a7a7db8a8e

"gdbus: Avoid printing null strings"



This patch should then be removed when we upgrade glib version.



diff --git a/gio/gdbusauth.c b/gio/gdbusauth.c
index 1f8ea80570cf910a45f3c7f4bb678789145b5d33..752ec23fccaec4b67ec470a9f04c1f2ce99e9809 100644
--- a/gio/gdbusauth.c
+++ b/gio/gdbusauth.c
@@ -1272,9 +1272,9 @@ _g_dbus_auth_run_server (GDBusAuth              *auth,
                                                     &line_length,
                                                     cancellable,
                                                     error);
-          debug_print ("SERVER: WaitingForBegin, read '%s'", line);
           if (line == NULL)
             goto out;
+          debug_print ("SERVER: WaitingForBegin, read '%s'", line);
           if (g_strcmp0 (line, "BEGIN") == 0)
             {
               /* YAY, done! */
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
index 3221b925d3ef4eff0b063f5f56cc0629131faf42..3a1a1f9e9101a3773620403d2cb6faf6209a1b64 100644
--- a/gio/gdbusmessage.c
+++ b/gio/gdbusmessage.c
@@ -2731,7 +2731,6 @@ g_dbus_message_to_blob (GDBusMessage          *message,
   if (message->body != NULL)
     {
       gchar *tupled_signature_str;
-      tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
       if (signature == NULL)
         {
           g_set_error (error,
@@ -2739,10 +2738,10 @@ g_dbus_message_to_blob (GDBusMessage          *message,
                        G_IO_ERROR_INVALID_ARGUMENT,
                        _("Message body has signature “%s” but there is no signature header"),
                        signature_str);
-          g_free (tupled_signature_str);
           goto out;
         }
-      else if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
+      tupled_signature_str = g_strdup_printf ("(%s)", signature_str);
+      if (g_strcmp0 (tupled_signature_str, g_variant_get_type_string (message->body)) != 0)
         {
           g_set_error (error,
                        G_IO_ERROR,