From f7443e0e854a59b5a97ef4bf7554da2db0f567b1 Mon Sep 17 00:00:00 2001 From: Elliot Lee Date: Thu, 1 Jan 1998 22:48:18 +0000 Subject: [PATCH] Fixed bug in get_length_upper_bound where g_print-ing a NULL string would cause a segfault --- glib/gstring.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/glib/gstring.c b/glib/gstring.c index eaadefd0eb..b803f67e51 100644 --- a/glib/gstring.c +++ b/glib/gstring.c @@ -322,6 +322,7 @@ get_length_upper_bound (gchar* fmt, va_list *args) int short_int; int long_int; int done; + char *tmp; while (*fmt) { @@ -362,7 +363,11 @@ get_length_upper_bound (gchar* fmt, va_list *args) /* I ignore 'q' and 'L', they're not portable anyway. */ case 's': - len += strlen (va_arg (*args, char *)); + tmp = va_arg(*args, char *); + if(tmp) + len += strlen (tmp); + else + len += strlen ("(null)"); done = TRUE; break; case 'd':