This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
[patch] Fix crash on CLI indented comments [Re: [Bug:cli] Loading user-defined function generates an internal error]
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Nick Roberts <nickrob at snap dot net dot nz>
- Cc: Joel Brobecker <brobecker at adacore dot com>, gdb at sourceware dot org, gdb-patches at sourceware dot org
- Date: Fri, 1 Jan 2010 09:40:28 +0100
- Subject: [patch] Fix crash on CLI indented comments [Re: [Bug:cli] Loading user-defined function generates an internal error]
- References: <19258.59036.731093.439412@totara.tehura.co.nz> <20091230054617.GA548@adacore.com> <19259.54163.166299.854635@totara.tehura.co.nz>
On Wed, 30 Dec 2009 23:26:27 +0100, Nick Roberts wrote:
> Heres a simpler user defined function that gives a segmentation fault. It
> appears that GDB can no longer handle indented comments.
>
> define my_fun
> #indented comment
> end
(*command)->line = savestring (p, p1 - p);
#1 0x0000000000487405 in savestring (ptr=0x1d5dd31 "", size=18446744073709551615) at utils.c:1377
(gdb) p/x size
$1 = 0xffffffffffffffff
(gdb) p p
$2 = 0x1d5dd31 ""
(gdb) p p1
$3 = 0x1d5dd30 " "
OK to check-in? Probably [obv].
Thanks,
Jan
2010-01-01 Jan Kratochvil <jan.kratochvil@redhat.com>
* cli/cli-script.c (process_next_line): Check P2 overrun.
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -893,7 +893,7 @@ process_next_line (char *p, struct command_line **command, int parse_commands)
p2 = p;
/* Strip leading whitespace. */
- while (*p2 == ' ' || *p2 == '\t')
+ while (p2 != p1 && (*p2 == ' ' || *p2 == '\t'))
p2++;
/* 'end' is always recognized, regardless of parse_commands value.