]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-33015: Use malloc() in PyThread_start_new_thread() (GH-10829)
authorVictor Stinner <vstinner@redhat.com>
Fri, 30 Nov 2018 17:08:02 +0000 (18:08 +0100)
committerGitHub <noreply@github.com>
Fri, 30 Nov 2018 17:08:02 +0000 (18:08 +0100)
The pthread implementation of PyThread_start_new_thread() now uses
malloc/free rather than PyMem_Malloc/PyMem_Free, since the latters
are not thread-safe.

Python/thread_pthread.h

index ae6b6b683904cefe4bbf8c080319e8a61d1dcd53..6d4b3b389f82d5e27b340940f4c8aeab4c2b98a8 100644 (file)
@@ -173,7 +173,7 @@ pythread_wrapper(void *arg)
     pythread_callback *callback = arg;
     void (*func)(void *) = callback->func;
     void *func_arg = callback->arg;
-    PyMem_Free(arg);
+    free(arg);
 
     func(func_arg);
     return NULL;
@@ -213,7 +213,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
     pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
 #endif
 
-    pythread_callback *callback = PyMem_Malloc(sizeof(pythread_callback));
+    pythread_callback *callback = malloc(sizeof(pythread_callback));
 
     if (callback == NULL) {
         return -1;
@@ -235,7 +235,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
 #endif
 
     if (status != 0) {
-        PyMem_Free(callback);
+        free(callback);
         return -1;
     }