summaryrefslogtreecommitdiffstats
path: root/Modules/faulthandler.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-07 21:30:24 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-07 21:30:24 (GMT)
commit49fc8ece8172162510890f42127d2aa4e13f878b (patch)
tree798c7555b232e40e607ec1b01cec87687515cf57 /Modules/faulthandler.c
parent6f8eeee7b9cae7e3f899c89baefe9acc575f2fb5 (diff)
downloadcpython-49fc8ece8172162510890f42127d2aa4e13f878b.zip
cpython-49fc8ece8172162510890f42127d2aa4e13f878b.tar.gz
cpython-49fc8ece8172162510890f42127d2aa4e13f878b.tar.bz2
Issue #18203: Add _PyMem_RawStrdup() and _PyMem_Strdup()
Replace strdup() with _PyMem_RawStrdup() or _PyMem_Strdup(), depending if the GIL is held or not.
Diffstat (limited to 'Modules/faulthandler.c')
-rw-r--r--Modules/faulthandler.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 686a45a..172945d 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -475,7 +475,7 @@ cancel_dump_traceback_later(void)
Py_CLEAR(thread.file);
if (thread.header) {
- free(thread.header);
+ PyMem_Free(thread.header);
thread.header = NULL;
}
}
@@ -504,7 +504,7 @@ format_timeout(double timeout)
"Timeout (%lu:%02lu:%02lu)!\n",
hour, min, sec);
- return strdup(buffer);
+ return _PyMem_Strdup(buffer);
}
static PyObject*
@@ -570,7 +570,7 @@ faulthandler_dump_traceback_later(PyObject *self,
if (PyThread_start_new_thread(faulthandler_thread, NULL) == -1) {
PyThread_release_lock(thread.running);
Py_CLEAR(thread.file);
- free(header);
+ PyMem_Free(header);
thread.header = NULL;
PyErr_SetString(PyExc_RuntimeError,
"unable to start watchdog thread");
@@ -729,9 +729,10 @@ faulthandler_register_py(PyObject *self,
return NULL;
if (user_signals == NULL) {
- user_signals = calloc(NSIG, sizeof(user_signal_t));
+ user_signals = PyMem_Malloc(NSIG * sizeof(user_signal_t));
if (user_signals == NULL)
return PyErr_NoMemory();
+ memset(user_signals, 0, NSIG * sizeof(user_signal_t));
}
user = &user_signals[signum];
@@ -1136,7 +1137,7 @@ void _PyFaulthandler_Fini(void)
if (user_signals != NULL) {
for (signum=0; signum < NSIG; signum++)
faulthandler_unregister(&user_signals[signum], signum);
- free(user_signals);
+ PyMem_Free(user_signals);
user_signals = NULL;
}
#endif