2007-06-28 Michael Snyder * 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. Index: event-top.c =================================================================== RCS file: /cvs/src/src/gdb/event-top.c,v retrieving revision 1.50 diff -p -r1.50 event-top.c *** event-top.c 9 Feb 2007 23:45:35 -0000 1.50 --- event-top.c 29 Jun 2007 02:00:03 -0000 *************** rl_callback_read_char_wrapper (gdb_clien *** 186,204 **** 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) { /* 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); strcpy (a_prompt, PREFIX (0)); strcat (a_prompt, gdb_prompt); strcat (a_prompt, SUFFIX (0)); --- 186,206 ---- void cli_command_loop (void) { /* 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); + make_cleanup (xfree, a_prompt); strcpy (a_prompt, PREFIX (0)); strcat (a_prompt, gdb_prompt); strcat (a_prompt, SUFFIX (0));