summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@specifix.com>2007-07-05 22:47:27 +0000
committerMichael Snyder <msnyder@specifix.com>2007-07-05 22:47:27 +0000
commite579a6684dc58ed1c8c350cbba3a5788e49ebf28 (patch)
tree6dc7be5c313e26eb12bc8cbb168c012ca8aaa70e
parentc73062c5e0a056f0a6b7add65cf50803e3987424 (diff)
downloadgdb-e579a6684dc58ed1c8c350cbba3a5788e49ebf28.tar.gz
2007-07-05 Michael Snyder <msnyder@access-company.com>
* event-top.c (cli_command_loop): Prompt string can (and should) be freed after call to readline (Coverity). Also move local var declarations into block where they are used. * tui/tui-interp.c (tui_command_loop): Prompt string can (and should) be freed after call to readline (Coverity). Also move local var declarations into block where they are used.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/event-top.c13
-rw-r--r--gdb/tui/tui-interp.c13
3 files changed, 24 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1b617a29121..b14389c684b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2007-07-05 Michael Snyder <msnyder@access-company.com>
+
+ * event-top.c (cli_command_loop): Prompt string can (and should)
+ be freed after call to readline (Coverity). Also move local var
+ declarations into block where they are used.
+
+ * tui/tui-interp.c (tui_command_loop): Prompt string can (and
+ should) be freed after call to readline (Coverity). Also move
+ local var declarations into block where they are used.
+
2007-07-03 Andreas Schwab <schwab@suse.de>
* linux-nat.c (linux_nat_info_proc_cmd): Fix parsing of columns in
diff --git a/gdb/event-top.c b/gdb/event-top.c
index 7765767c3dc..eecff5a0639 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -186,19 +186,20 @@ rl_callback_read_char_wrapper (gdb_client_data client_data)
void
cli_command_loop (void)
{
- int length;
- char *a_prompt;
- char *gdb_prompt = get_prompt ();
-
/* If we are using readline, set things up and display the first
prompt, otherwise just print the prompt. */
if (async_command_editing_p)
{
+ int length;
+ char *a_prompt;
+ char *gdb_prompt = get_prompt ();
+
/* Tell readline what the prompt to display is and what function it
will need to call after a whole line is read. This also displays
the first prompt. */
- length = strlen (PREFIX (0)) + strlen (gdb_prompt) + strlen (SUFFIX (0)) + 1;
- a_prompt = (char *) xmalloc (length);
+ length = strlen (PREFIX (0))
+ + strlen (gdb_prompt) + strlen (SUFFIX (0)) + 1;
+ a_prompt = (char *) alloca (length);
strcpy (a_prompt, PREFIX (0));
strcat (a_prompt, gdb_prompt);
strcat (a_prompt, SUFFIX (0));
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index a344754250c..292c7db95f3 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -119,19 +119,20 @@ tui_exec (void *data, const char *command_str)
static void
tui_command_loop (void *data)
{
- int length;
- char *a_prompt;
- char *gdb_prompt = get_prompt ();
-
/* If we are using readline, set things up and display the first
prompt, otherwise just print the prompt. */
if (async_command_editing_p)
{
+ int length;
+ char *a_prompt;
+ char *gdb_prompt = get_prompt ();
+
/* Tell readline what the prompt to display is and what function
it will need to call after a whole line is read. This also
displays the first prompt. */
- length = strlen (PREFIX (0)) + strlen (gdb_prompt) + strlen (SUFFIX (0)) + 1;
- a_prompt = (char *) xmalloc (length);
+ length = strlen (PREFIX (0))
+ + strlen (gdb_prompt) + strlen (SUFFIX (0)) + 1;
+ a_prompt = (char *) alloca (length);
strcpy (a_prompt, PREFIX (0));
strcat (a_prompt, gdb_prompt);
strcat (a_prompt, SUFFIX (0));