This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Change reopen_exec_file to check result of stat


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=537d9b851957475a8122949939023c81b1df1673

commit 537d9b851957475a8122949939023c81b1df1673
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Jun 6 13:01:52 2016 -0600

    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.

Diff:
---
 gdb/ChangeLog  | 5 +++++
 gdb/corefile.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ba207ba..cef090c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-07-14  Tom Tromey  <tom@tromey.com>
+
+	* corefile.c (reopen_exec_file): Only examine st.st_mtime if stat
+	succeeded.
+
 2016-07-13  Tom Tromey  <tom@tromey.com>
 
 	PR python/15620, PR python/18620:
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 6cc2afc..64de931 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;


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