aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-06-06 13:01:52 -0600
committerTom Tromey <tom@tromey.com>2016-07-14 10:35:37 -0600
commit537d9b851957475a8122949939023c81b1df1673 (patch)
tree322af5510c2c4aa16f1311ebce1c9105216e26ee /gdb/corefile.c
parentobjcopy/strip: Add option --remove-relocations=SECTIONPATTERN (diff)
downloadbinutils-gdb-537d9b851957475a8122949939023c81b1df1673.tar.gz
binutils-gdb-537d9b851957475a8122949939023c81b1df1673.tar.bz2
binutils-gdb-537d9b851957475a8122949939023c81b1df1673.zip
Change reopen_exec_file to check result of stat
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-07-14 Tom Tromey <tom@tromey.com> * corefile.c (reopen_exec_file): Only examine st.st_mtime if stat succeeded.
Diffstat (limited to 'gdb/corefile.c')
-rw-r--r--gdb/corefile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 6cc2afc49e8..64de931b167 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -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;