Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hal Ashburner <hal@ashburner.info>
To: "Abid, Hafiz" <Hafiz_Abid@mentor.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb: trivial segfault fix in tui
Date: Tue, 14 Aug 2012 23:03:00 -0000	[thread overview]
Message-ID: <CACCZV9b3NGszuf2W1vYRrFkQ=iAMADh6QOC6ceHr44mKRqeV3A@mail.gmail.com> (raw)
In-Reply-To: <EB3B29AD43CA924DA27099BC851923762A231D@EU-MBX-03.mgc.mentorg.com>

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 <hal@ashburner.info>
+
+   * tui/tui-source.c: Check for null pointer to prevent segfault.
+
 2012-08-10  Sergio Durigan Junior  <sergiodj@redhat.com>

    * 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 <Hafiz_Abid@mentor.com> 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


  reply	other threads:[~2012-08-14 23:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-12 16:13 Hal Ashburner
2012-08-14 10:55 ` Abid, Hafiz
2012-08-14 23:03   ` Hal Ashburner [this message]
2012-08-15  0:34     ` Doug Evans
2012-08-16  1:50       ` Hal Ashburner
2012-08-27 17:06         ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACCZV9b3NGszuf2W1vYRrFkQ=iAMADh6QOC6ceHr44mKRqeV3A@mail.gmail.com' \
    --to=hal@ashburner.info \
    --cc=Hafiz_Abid@mentor.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox