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.
This commit is contained in:
Tom Tromey 2016-06-06 13:01:52 -06:00
parent d3e5f6c8f1
commit 537d9b8519
2 changed files with 6 additions and 1 deletions

View 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:

View 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;