diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f35ba1b210..67049161c2 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-08-19 Jan Kratochvil + + Fix -fsanitize=address on unreadable inferior strings. + * valprint.c (val_print_string): Fix access before BUFFER. + 2014-08-19 Simon Marchi * target.c (target_struct_size): Remove. diff --git a/gdb/valprint.c b/gdb/valprint.c index d3ab2675fc..a87d67cc78 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -2510,8 +2510,10 @@ val_print_string (struct type *elttype, const char *encoding, LEN is -1. */ /* Determine found_nul by looking at the last character read. */ - found_nul = extract_unsigned_integer (buffer + bytes_read - width, width, - byte_order) == 0; + found_nul = 0; + if (bytes_read >= width) + found_nul = extract_unsigned_integer (buffer + bytes_read - width, width, + byte_order) == 0; if (len == -1 && !found_nul) { gdb_byte *peekbuf;