PATCH: Fix TUI null pointer dereference

Andrew STUBBS andrew.stubbs@st.com
Mon Oct 24 13:32:00 GMT 2005


Jim Blandy wrote:
> Andrew STUBBS <andrew.stubbs@st.com> writes:
> 
>>Index: src/gdb/tui/tui-command.c
>>===================================================================
>>--- src.orig/gdb/tui/tui-command.c	2004-02-16 21:05:09.000000000 +0000
>>+++ src/gdb/tui/tui-command.c	2005-10-17 14:33:06.000000000 +0100
>>@@ -70,7 +70,7 @@ tui_dispatch_ctrl_char (unsigned int ch)
>>       term = (char *) getenv ("TERM");
>>       for (i = 0; (term && term[i]); i++)
>> 	term[i] = toupper (term[i]);
>>-      if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch))
>>+      if (term && (strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch))
>> 	{
>> 	  unsigned int page_ch = 0;
>> 	  unsigned int tmp_char;
> 
> 
> How about wrapping the upcasing loop and the 'if' after it all in one
> big 'if (term), starting right after the 'getenv ("TERM")', and then
> simplifying the conditional in the upcasing loop?
> 

How about the attached? Diff has made it look rather confusing, but I 
assure you the only thing that has changed is the indenting and the 
extra if.

Andrew Stubbs
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tui-NULL-pointer.patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20051024/244c9264/attachment.ksh>


More information about the Gdb-patches mailing list