From 1709db4953bcfcfca5447be106d296b49cd7955d Mon Sep 17 00:00:00 2001 From: "William E. Kempf" Date: Thu, 3 Jul 2003 13:31:27 +0000 Subject: [PATCH] Fixed exception handling bug in once.cpp. [SVN r18933] --- src/once.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/once.cpp b/src/once.cpp index 851adf63..e829542b 100644 --- a/src/once.cpp +++ b/src/once.cpp @@ -127,7 +127,7 @@ void call_once(void (*func)(), once_flag& flag) strm << "2AC1A572DB6944B0A65C38C4140AF2F4" << std::hex << GetCurrentProcessId() << &flag << std::ends; unfreezer unfreeze(strm); - HANDLE mutex = CreateMutex(NULL, FALSE, strm.str()); + HANDLE mutex = CreateMutexA(NULL, FALSE, strm.str()); #else std::ostringstream strm; strm << "2AC1A572DB6944B0A65C38C4140AF2F4" << std::hex @@ -142,7 +142,18 @@ void call_once(void (*func)(), once_flag& flag) if (compare_exchange(&flag, 1, 1) == 0) { - func(); + try + { + func(); + } + catch (...) + { + res = ReleaseMutex(mutex); + assert(res); + res = CloseHandle(mutex); + assert(res); + throw; + } InterlockedExchange(&flag, 1); }