From: Pascal Obry Date: Fri, 22 Aug 2008 13:26:38 +0000 (+0200) Subject: adaint.c: Fix possible race condition on win32_wait(). X-Git-Tag: releases/gcc-4.4.0~2941 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23922a2f6acfcbdf13363db7ddf4fcf3aa4dfc79;p=thirdparty%2Fgcc.git adaint.c: Fix possible race condition on win32_wait(). 2008-08-22 Pascal Obry * adaint.c: Fix possible race condition on win32_wait(). From-SVN: r139466 --- diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 48abb3e5049e..0971a028b3a9 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -2266,6 +2266,7 @@ win32_wait (int *status) DWORD res; int k; Process_List *pl; + int hl_len; if (plist_length == 0) { @@ -2273,12 +2274,14 @@ win32_wait (int *status) return -1; } - hl = (HANDLE *) xmalloc (sizeof (HANDLE) * plist_length); - k = 0; plist_enter(); + hl_len = plist_length; + /* -------------------- critical section -------------------- */ + hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len); + pl = PLIST; while (pl) { @@ -2289,7 +2292,7 @@ win32_wait (int *status) plist_leave(); - res = WaitForMultipleObjects (plist_length, hl, FALSE, INFINITE); + res = WaitForMultipleObjects (hl_len, hl, FALSE, INFINITE); h = hl[res - WAIT_OBJECT_0]; free (hl);