From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18556 invoked by alias); 14 Aug 2012 23:03:47 -0000 Received: (qmail 18541 invoked by uid 22791); 14 Aug 2012 23:03:46 -0000 X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-we0-f169.google.com (HELO mail-we0-f169.google.com) (74.125.82.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Aug 2012 23:03:33 +0000 Received: by weys10 with SMTP id s10so745739wey.0 for ; Tue, 14 Aug 2012 16:03:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.255.146 with SMTP id j18mr8908590wes.163.1344985412436; Tue, 14 Aug 2012 16:03:32 -0700 (PDT) Received: by 10.227.156.81 with HTTP; Tue, 14 Aug 2012 16:03:32 -0700 (PDT) In-Reply-To: References: Date: Tue, 14 Aug 2012 23:03:00 -0000 Message-ID: Subject: Re: [PATCH] gdb: trivial segfault fix in tui From: Hal Ashburner To: "Abid, Hafiz" Cc: "gdb-patches@sourceware.org" Content-Type: text/plain; charset=ISO-8859-1 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00421.txt.bz2 Dear Hafiz, Thank you for letting me know this. I've added a ChangeLog entry to the patch. I hope this is done the correct way. By way of trivia, I fixed this bug because I hit it more than once. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 81c03ee..e1a080f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2012-08-15 Hal Ashburner + + * tui/tui-source.c: Check for null pointer to prevent segfault. + 2012-08-10 Sergio Durigan Junior * linespec.c (find_methods): Remove unused variables `i1' and diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c index 9ba9b1d..0c94aed 100644 --- a/gdb/tui/tui-source.c +++ b/gdb/tui/tui-source.c @@ -334,11 +334,13 @@ tui_show_symtab_source (struct gdbarch *gdbarch, struct symtab *s, int tui_source_is_displayed (char *fname) { - return (TUI_SRC_WIN->generic.content_in_use - && (filename_cmp (((struct tui_win_element *) - (tui_locator_win_info_ptr ())-> - content[0])->which_element.locator.file_name, - fname) == 0)); + if (tui_locator_win_info_ptr()->content) + return (TUI_SRC_WIN->generic.content_in_use + && (filename_cmp (((struct tui_win_element *) + (tui_locator_win_info_ptr ())-> + content[0])->which_element.locator.file_name, + fname) == 0)); + return 0; } On 14 August 2012 20:55, Abid, Hafiz wrote: > This will require a ChangeLog entry. > > Regards, > Abid > -- > Hafiz Abid Qadeer > Mentor Graphics > hafiz_abid@mentor.com > >> -----Original Message----- >> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches- >> owner@sourceware.org] On Behalf Of Hal Ashburner >> Sent: Sunday, August 12, 2012 5:13 PM >> To: gdb-patches@sourceware.org >> Subject: [PATCH] gdb: trivial segfault fix in tui >> >> Hello! >> >> I hope this is the correct etiquette and that it's useful. Copyright >> assigned to whoever commits to assign to GNU or do whatever is >> appropriate (assuming it is committed). >> >> To the easiest way to replicate the segfault: >> gdb some_prog >> b main >> run >> C-x a >> C-x 2 >> C-x 2 >> C-x 2 -- so you now have registers on the top panel and source in the >> middle. >> resize the terminal. >> step, >> segfault >> >> Regards, >> Hal