This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gdb: trivial segfault fix in tui


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]