[Ada] Fix computation of handle/pid lists in win32_wait
authorPascal Obry <obry@adacore.com>
Wed, 23 May 2018 10:23:59 +0000 (10:23 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Wed, 23 May 2018 10:23:59 +0000 (10:23 +0000)
An obvious mistake due to missing parentheses was not properly computing the
size of the handle and pid list passed to WaitForMultipleObjects(). This
resulted in a memory corruption.

2018-05-23  Pascal Obry  <obry@adacore.com>

gcc/ada/

* adaint.c (win32_wait): Add missing parentheses.

From-SVN: r260598

gcc/ada/ChangeLog
gcc/ada/adaint.c

index e1f83b5..c2df68d 100644 (file)
@@ -1,3 +1,7 @@
+2018-05-23  Pascal Obry  <obry@adacore.com>
+
+       * adaint.c (win32_wait): Add missing parentheses.
+
 2018-05-23  Hristian Kirtchev  <kirtchev@adacore.com>
 
        * exp_ch3.adb (Check_Large_Modular_Array): Moved to Freeze.
index 9e0919e..07e55e4 100644 (file)
@@ -2591,10 +2591,10 @@ win32_wait (int *status)
 #else
   /* Note that index 0 contains the event handle that is signaled when the
      process list has changed */
-  hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len + 1);
+  hl = (HANDLE *) xmalloc (sizeof (HANDLE) * (hl_len + 1));
   hl[0] = ProcListEvt;
   memmove (&hl[1], HANDLES_LIST, sizeof (HANDLE) * hl_len);
-  pidl = (int *) xmalloc (sizeof (int) * hl_len + 1);
+  pidl = (int *) xmalloc (sizeof (int) * (hl_len + 1));
   memmove (&pidl[1], PID_LIST, sizeof (int) * hl_len);
   hl_len++;
 #endif