diff mbox series

Fix use-after-scope in host-mingw32.c (PR target/88056).

Message ID 7b029e84-8b3a-aa5a-7975-dd7618bcf996@suse.cz
State New
Headers show
Series Fix use-after-scope in host-mingw32.c (PR target/88056). | expand

Commit Message

Martin Liška July 1, 2019, 9:35 a.m. UTC
Hi.

The patch is about use-after-scope. However, I can't verify
it survives bootstrap on the affected target.

Ready for the trunk?
Thanks,
Martin

gcc/ChangeLog:

2019-07-01  Martin Liska  <mliska@suse.cz>

	PR target/88056
	* config/i386/host-mingw32.c (mingw32_gt_pch_use_address):
	Define local_object_name in outer scope in order to handle
	use-after-scope issue.
---
 gcc/config/i386/host-mingw32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jeff Law July 2, 2019, 7:58 p.m. UTC | #1
On 7/1/19 3:35 AM, Martin Liška wrote:
> Hi.
> 
> The patch is about use-after-scope. However, I can't verify
> it survives bootstrap on the affected target.
> 
> Ready for the trunk?
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
> 2019-07-01  Martin Liska  <mliska@suse.cz>
> 
> 	PR target/88056
> 	* config/i386/host-mingw32.c (mingw32_gt_pch_use_address):
> 	Define local_object_name in outer scope in order to handle
> 	use-after-scope issue.
OK
jeff
diff mbox series

Patch

diff --git a/gcc/config/i386/host-mingw32.c b/gcc/config/i386/host-mingw32.c
index f2b56d71c5b..3254d028313 100644
--- a/gcc/config/i386/host-mingw32.c
+++ b/gcc/config/i386/host-mingw32.c
@@ -157,10 +157,10 @@  mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
   /* Determine the version of Windows we are running on and use a
      uniquely-named local object if running > 4.  */
   GetVersionEx (&version_info);
+
+  char local_object_name[sizeof (OBJECT_NAME_FMT) + sizeof (DWORD) * 2];
   if (version_info.dwMajorVersion > 4)
     {
-      char local_object_name [sizeof (OBJECT_NAME_FMT)
-			      + sizeof (DWORD) * 2];
       snprintf (local_object_name, sizeof (local_object_name),
 		OBJECT_NAME_FMT "%lx", GetCurrentProcessId());
       object_name = local_object_name;