From: Victor Stinner Date: Sun, 7 Jul 2013 15:07:52 +0000 (+0200) Subject: Issue #18203: Replace malloc() with PyMem_Malloc() in _ssl for the password X-Git-Tag: v3.4.0a1~299 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=11ebff2757517f6edf8c4b35d6c77b7052295acb;p=thirdparty%2FPython%2Fcpython.git Issue #18203: Replace malloc() with PyMem_Malloc() in _ssl for the password --- diff --git a/Modules/_ssl.c b/Modules/_ssl.c index ff3ef9eeeb19..4e619b80fd16 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -2070,8 +2070,8 @@ _pwinfo_set(_PySSLPasswordInfo *pw_info, PyObject* password, goto error; } - free(pw_info->password); - pw_info->password = malloc(size); + PyMem_Free(pw_info->password); + pw_info->password = PyMem_Malloc(size); if (!pw_info->password) { PyErr_SetString(PyExc_MemoryError, "unable to allocate password buffer"); @@ -2215,13 +2215,13 @@ load_cert_chain(PySSLContext *self, PyObject *args, PyObject *kwds) } SSL_CTX_set_default_passwd_cb(self->ctx, orig_passwd_cb); SSL_CTX_set_default_passwd_cb_userdata(self->ctx, orig_passwd_userdata); - free(pw_info.password); + PyMem_Free(pw_info.password); Py_RETURN_NONE; error: SSL_CTX_set_default_passwd_cb(self->ctx, orig_passwd_cb); SSL_CTX_set_default_passwd_cb_userdata(self->ctx, orig_passwd_userdata); - free(pw_info.password); + PyMem_Free(pw_info.password); Py_XDECREF(keyfile_bytes); Py_XDECREF(certfile_bytes); return NULL;