aboutsummaryrefslogtreecommitdiff
path: root/gdb/ch-valprint.c
diff options
context:
space:
mode:
authorJim Blandy <jimb@codesourcery.com>1997-12-10 22:58:21 +0000
committerJim Blandy <jimb@codesourcery.com>1997-12-10 22:58:21 +0000
commitbf6a4419d6245366603f29a990a4d07080c746dc (patch)
tree42c1fd22c404a78b8cd5c6d16ed7184e20cb593a /gdb/ch-valprint.c
parentb2839a56022b6971457cc6d09c8efd06fdc3d371 (diff)
downloadgdb-bf6a4419d6245366603f29a990a4d07080c746dc.zip
gdb-bf6a4419d6245366603f29a990a4d07080c746dc.tar.gz
gdb-bf6a4419d6245366603f29a990a4d07080c746dc.tar.bz2
* ch-valprint.c (chill_val_print): To avoid segfaults, don't print
a string whose dynamic length is longer than its static length.
Diffstat (limited to 'gdb/ch-valprint.c')
-rw-r--r--gdb/ch-valprint.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/ch-valprint.c b/gdb/ch-valprint.c
index 796172f..911c693 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,
- "<dynamic length %ld > static length %d>",
+ "<dynamic length %ld > 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;