Skip to content

Commit bc9f53f

Browse files
authored
bpo-33015: Use malloc() in PyThread_start_new_thread() (GH-10829)
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.
1 parent 8f83c2f commit bc9f53f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Python/thread_pthread.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pythread_wrapper(void *arg)
173173
pythread_callback *callback = arg;
174174
void (*func)(void *) = callback->func;
175175
void *func_arg = callback->arg;
176-
PyMem_Free(arg);
176+
free(arg);
177177

178178
func(func_arg);
179179
return NULL;
@@ -213,7 +213,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
213213
pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
214214
#endif
215215

216-
pythread_callback *callback = PyMem_Malloc(sizeof(pythread_callback));
216+
pythread_callback *callback = malloc(sizeof(pythread_callback));
217217

218218
if (callback == NULL) {
219219
return -1;
@@ -235,7 +235,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
235235
#endif
236236

237237
if (status != 0) {
238-
PyMem_Free(callback);
238+
free(callback);
239239
return -1;
240240
}
241241

0 commit comments

Comments
 (0)