diff options
author | Tom Tromey <tom@tromey.com> | 2018-02-14 11:12:17 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-03-14 09:44:33 -0600 |
commit | b8c2339b2f46d4885b933b832fc5b37c7ca101a6 (patch) | |
tree | 58f253f8bc6c9571867c638dd71daff548ea5436 /gdb/printcmd.c | |
parent | 80ae639d3cc4f1e83f1ad48686f87417c06ca6dc (diff) | |
download | fsf-binutils-gdb-b8c2339b2f46d4885b933b832fc5b37c7ca101a6.zip fsf-binutils-gdb-b8c2339b2f46d4885b933b832fc5b37c7ca101a6.tar.gz fsf-binutils-gdb-b8c2339b2f46d4885b933b832fc5b37c7ca101a6.tar.bz2 |
Allow - in %p for printf
PR cli/19918 points out that a printf format like "%-5p" will cause a
gdb crash. The bug is problem is that printf_pointer doesn't take the
"-" flag into account.
gdb/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/19918:
* printcmd.c (printf_pointer): Allow "-" in format.
gdb/testsuite/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/19918:
* gdb.base/printcmds.exp (test_printf): Add printf test using '-'
flag.
Diffstat (limited to 'gdb/printcmd.c')
-rw-r--r-- | gdb/printcmd.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 13b967f..17c67ee 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -2399,8 +2399,9 @@ printf_pointer (struct ui_file *stream, const char *format, if (val != 0) *fmt_p++ = '#'; - /* Copy any width. */ - while (*p >= '0' && *p < '9') + /* Copy any width or flags. Only the "-" flag is valid for pointers + -- see the format_pieces constructor. */ + while (*p == '-' || (*p >= '0' && *p < '9')) *fmt_p++ = *p++; gdb_assert (*p == 'p' && *(p + 1) == '\0'); |