[Python-checkins] cpython: Issue #18203: Replace malloc() with PyMem_Malloc() in _ssl for the password

victor.stinner python-checkins at python.org
Sun Jul 7 17:26:33 CEST 2013


http://hg.python.org/cpython/rev/638d43665356
changeset:   84495:638d43665356
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Sun Jul 07 17:07:52 2013 +0200
summary:
  Issue #18203: Replace malloc() with PyMem_Malloc() in _ssl for the password

files:
  Modules/_ssl.c |  8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/Modules/_ssl.c b/Modules/_ssl.c
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -2070,8 +2070,8 @@
         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 @@
     }
     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;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list