Change reopen_exec_file to check result of stat
authorTom Tromey <tom@tromey.com>
Mon, 6 Jun 2016 19:01:52 +0000 (13:01 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 14 Jul 2016 16:35:37 +0000 (10:35 -0600)
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.

gdb/ChangeLog
gdb/corefile.c

index ba207ba949606565a6a0d0b1921b532b592e2f1f..cef090cc3dce267effa958c41b0cc97ece0fb1a2 100644 (file)
@@ -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:
index 6cc2afc49e816e2dbefe45266e2977df1a5e4176..64de931b167dbf59110a8a0970d1731e4325ee9a 100644 (file)
@@ -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;
This page took 0.02913 seconds and 4 git commands to generate.