[RFA,1/6] Change reopen_exec_file to check result of stat
Commit Message
This seems to be a real bug found by -Wunused-but-set-variable. If
"stat" fails for some reason, gdb would use the uninitialized "st".
2016-06-06 Tom Tromey <tom@tromey.com>
* corefile.c (reopen_exec_file): Only examine st.st_mtime if stat
succeeded.
---
gdb/ChangeLog | 5 +++++
gdb/corefile.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
Comments
On Mon, Jun 6, 2016 at 10:33 PM, Tom Tromey <tom@tromey.com> wrote:
> This seems to be a real bug found by -Wunused-but-set-variable. If
> "stat" fails for some reason, gdb would use the uninitialized "st".
>
> 2016-06-06 Tom Tromey <tom@tromey.com>
>
> * corefile.c (reopen_exec_file): Only examine st.st_mtime if stat
> succeeded.
Patch is good to me.
@@ -1,3 +1,8 @@
+2016-06-06 Tom Tromey <tom@tromey.com>
+
+ * corefile.c (reopen_exec_file): Only examine st.st_mtime if stat
+ succeeded.
+
2016-06-02 Jon Turney <jon.turney@dronecode.org.uk>
* windows-nat.c (handle_output_debug_string): Return type of
@@ -144,7 +144,7 @@ reopen_exec_file (void)
cleanups = make_cleanup (xfree, filename);
res = stat (filename, &st);
- if (exec_bfd_mtime && exec_bfd_mtime != st.st_mtime)
+ if (res == 0 && exec_bfd_mtime && exec_bfd_mtime != st.st_mtime)
exec_file_attach (filename, 0);
else
/* If we accessed the file since last opening it, close it now;