From 961ccde634c48fe95887cbfc5e3d15debc4d4818 Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Thu, 18 Feb 1993 23:49:40 +0000 Subject: [PATCH] Bugfix for length==0 case. --- gdb/ChangeLog | 2 ++ gdb/c-lang.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b528a99..9d4cc84 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,7 @@ Thu Feb 18 04:10:06 1993 John Gilmore (gnu@cygnus.com) + * c-lang.c (c_printstr): Bugfix for length==0 case. + * c-lang.c (c_printstr): If a C string ends in a null, don't print the null. diff --git a/gdb/c-lang.c b/gdb/c-lang.c index bfa03d0..b96dc1e 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -111,7 +111,7 @@ c_printstr (stream, string, length, force_ellipses) /* If the string was not truncated due to `set print elements', and the last byte of it is a null, we don't print that, in traditional C style. */ - if ((!force_ellipses) && string[length-1] == '\0') + if ((!force_ellipses) && length > 0 && string[length-1] == '\0') length--; if (length == 0) -- 2.7.4