Fix use-after-scope in host-mingw32.c (PR target/88056).
authorMartin Liska <mliska@suse.cz>
Wed, 3 Jul 2019 08:29:48 +0000 (10:29 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 3 Jul 2019 08:29:48 +0000 (08:29 +0000)
2019-07-03  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.

From-SVN: r272991

gcc/ChangeLog
gcc/config/i386/host-mingw32.c

index ca9ca7bfd06c936ff65e9a28607c192021fd7f4c..3d1a07acb4010b195a36131e936b6cd7c623b415 100644 (file)
@@ -1,3 +1,10 @@
+2019-07-03  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.
+
 2019-07-03  Martin Liska  <mliska@suse.cz>
 
        * common.opt: Add fprofile-note.
index f2b56d71c5b0d2ec3fb7b5b6e4bb3ac9b6fdcd25..3254d0283131ea08be3af6df8f9cad45e19de401 100644 (file)
@@ -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;