diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-12 14:29:48 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-11-12 14:29:48 +0200 |
commit | e7ed9c7bd2204dd48d67eb7b14813c0338a85a0c (patch) | |
tree | fdcf7d7cba9df4da905bfc99dd42ddc7cfe15138 /Python/thread_nt.h | |
parent | 4a994ab2dc58b8fd66549ea28eb489e8009d19d7 (diff) | |
parent | 5f7236d4e16f4f4eee4da97621a6f8a225dfba4e (diff) | |
download | cpython-e7ed9c7bd2204dd48d67eb7b14813c0338a85a0c.tar.gz |
Issue #28648: Fixed crash in Py_DecodeLocale() in debug build on Mac OS X
when decode astral characters.
Diffstat (limited to 'Python/thread_nt.h')
-rw-r--r-- | Python/thread_nt.h | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/Python/thread_nt.h b/Python/thread_nt.h index b157fc54a9..84452cdac4 100644 --- a/Python/thread_nt.h +++ b/Python/thread_nt.h @@ -34,7 +34,7 @@ typedef NRMUTEX *PNRMUTEX; PNRMUTEX AllocNonRecursiveMutex() { - PNRMUTEX m = (PNRMUTEX)malloc(sizeof(NRMUTEX)); + PNRMUTEX m = (PNRMUTEX)PyMem_RawMalloc(sizeof(NRMUTEX)); if (!m) return NULL; if (PyCOND_INIT(&m->cv)) @@ -46,7 +46,7 @@ AllocNonRecursiveMutex() m->locked = 0; return m; fail: - free(m); + PyMem_RawFree(m); return NULL; } @@ -56,7 +56,7 @@ FreeNonRecursiveMutex(PNRMUTEX mutex) if (mutex) { PyCOND_FINI(&mutex->cv); PyMUTEX_FINI(&mutex->cs); - free(mutex); + PyMem_RawFree(mutex); } } @@ -107,7 +107,7 @@ LeaveNonRecursiveMutex(PNRMUTEX mutex) result = PyCOND_SIGNAL(&mutex->cv); result &= PyMUTEX_UNLOCK(&mutex->cs); return result; -} +} #else /* if ! _PY_USE_CV_LOCKS */ @@ -130,7 +130,7 @@ FreeNonRecursiveMutex(PNRMUTEX mutex) DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds) { - return WaitForSingleObject(mutex, milliseconds); + return WaitForSingleObjectEx(mutex, milliseconds, FALSE); } BOOL @@ -389,20 +389,11 @@ PyThread_delete_key(int key) TlsFree(key); } -/* We must be careful to emulate the strange semantics implemented in thread.c, - * where the value is only set if it hasn't been set before. - */ int PyThread_set_key_value(int key, void *value) { BOOL ok; - void *oldvalue; - assert(value != NULL); - oldvalue = TlsGetValue(key); - if (oldvalue != NULL) - /* ignore value if already set */ - return 0; ok = TlsSetValue(key, value); if (!ok) return -1; |