From bf6a4419d6245366603f29a990a4d07080c746dc Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 10 Dec 1997 22:58:21 +0000 Subject: [PATCH] * ch-valprint.c (chill_val_print): To avoid segfaults, don't print a string whose dynamic length is longer than its static length. --- gdb/ch-valprint.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c index 796172fb173..911c693f3c0 100644 --- a/gdb/ch-valprint.c +++ b/gdb/ch-valprint.c @@ -422,11 +422,15 @@ chill_val_print (type, valaddr, address, stream, format, deref_ref, recurse, switch (TYPE_CODE (inner)) { case TYPE_CODE_STRING: - if (length > TYPE_LENGTH (type)) + if (length > TYPE_LENGTH (type) - 2) { fprintf_filtered (stream, - " static length %d>", + " static length %d> *invalid*", length, TYPE_LENGTH (type)); + + /* Don't print the string; doing so might produce a + segfault. */ + return length; } LA_PRINT_STRING (stream, data_addr, length, 0); return length; -- 2.30.2