[glib] g_dbus_error_encode_gerror: don't segfault on bad domains



commit e60e4999b9d4904b74e1a38bd5c24b9fd047f95d
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Thu Sep 29 13:57:09 2011 +0100

    g_dbus_error_encode_gerror: don't segfault on bad domains
    
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
    Reviewed-by: Matthias Clasen <mclasen redhat com>
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=660371

 gio/gdbuserror.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/gio/gdbuserror.c b/gio/gdbuserror.c
index 064c67b..946670a 100644
--- a/gio/gdbuserror.c
+++ b/gio/gdbuserror.c
@@ -837,6 +837,10 @@ g_dbus_error_encode_gerror (const GError *error)
        * hex-encode it for transport across the wire.
        */
       domain_as_string = g_quark_to_string (error->domain);
+
+      /* 0 is not a domain; neither are non-quark integers */
+      g_return_val_if_fail (domain_as_string != NULL, NULL);
+
       s = g_string_new ("org.gtk.GDBus.UnmappedGError.Quark._");
       for (n = 0; domain_as_string[n] != 0; n++)
         {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]