x11: Don't assume valid type
authorDr. David Alan Gilbert <dave@treblig.org>
Sat, 30 Jul 2022 15:39:18 +0000 (16:39 +0100)
committerDr. David Alan Gilbert <dave@treblig.org>
Sat, 30 Jul 2022 21:11:59 +0000 (22:11 +0100)
If we get an invalid TARGETS reply, we might not have a valid 'type',
which ends up as NULL and segs in the g_str_equal.

(This is probably fallout from my fix 506566b6a4c3a9, which I still
can't reproduce reliably, so the last one just moved the seg a bit
further along, and we still don't know who is sending a bad TARGETS).

This corresponds to:
https://bugzilla.redhat.com/show_bug.cgi?id=2062143

gdk/x11/gdkclipboard-x11.c

index db2815ed528af18fd8a84068628da2fa6400165e..f634536b3f01beebeed668170514bb6f4f54581a 100644 (file)
@@ -358,10 +358,10 @@ gdk_x11_clipboard_request_targets_got_stream (GObject      *source,
       g_error_free (error);
       return;
     }
-  else if (!g_str_equal (type, "ATOM") || format != 32)
+  else if (g_strcmp0 (type, "ATOM") != 0 || format != 32)
     {
       GDK_DISPLAY_NOTE (display, CLIPBOARD, g_printerr ("%s: Wrong reply type to TARGETS: type %s != ATOM or format %d != 32\n",
-                                      cb->selection, type, format));
+                                      cb->selection, type ? type : "NULL", format));
       g_input_stream_close (stream, NULL, NULL);
       g_object_unref (stream);
       g_object_unref (cb);