[1/3] Correctly initialize the TUI locator window

Message ID 1435372525-1374-1-git-send-email-patrick@parcs.ath.cx
State New, archived
Headers

Commit Message

Patrick Palka June 27, 2015, 2:35 a.m. UTC
  The call to tui_alloc_content in tui_set_locator_info passes
locator->type as the type of the window whose content is being
allocated.  This may seem correct but it's actually not because when
this code path actually get executed locator->type has not yet been to
set LOCATOR_WIN so it defaults to 0 i.e. SRC_WIN.  Thus we allocate the
content of the locator window as if it was the source window.  This
oversight turns out not to be a big deal in practice but the patch that
follows depends on the locator's proc_name and full_name arrays to be
initialized to the empty string which is done by tui_alloc_content if
we pass to it LOCATOR_WIN.

This patch fixes this bug by explicitly passing LOCATOR_WIN to
tui_alloc_content.

gdb/ChangeLog:

	* tui/tui-stack.c (tui_set_locator_info): Explicitly pass
	LOCATOR_WIN to tui_alloc_content.
---
 gdb/tui/tui-stack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Pedro Alves June 30, 2015, 8:36 a.m. UTC | #1
On 06/27/2015 03:35 AM, Patrick Palka wrote:
> The call to tui_alloc_content in tui_set_locator_info passes
> locator->type as the type of the window whose content is being
> allocated.  This may seem correct but it's actually not because when
> this code path actually get executed locator->type has not yet been to
> set LOCATOR_WIN so it defaults to 0 i.e. SRC_WIN.  Thus we allocate the
> content of the locator window as if it was the source window.  This
> oversight turns out not to be a big deal in practice but the patch that
> follows depends on the locator's proc_name and full_name arrays to be
> initialized to the empty string which is done by tui_alloc_content if
> we pass to it LOCATOR_WIN.
> 
> This patch fixes this bug by explicitly passing LOCATOR_WIN to
> tui_alloc_content.

OK.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 2870d70..b17d303 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -306,7 +306,7 @@  tui_set_locator_info (struct gdbarch *gdbarch,
   /* Allocate the locator content if necessary.  */
   if (locator->content_size <= 0)
     {
-      locator->content = tui_alloc_content (1, locator->type);
+      locator->content = tui_alloc_content (1, LOCATOR_WIN);
       locator->content_size = 1;
     }