Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integer

overflows.  Added few missed PyErr_NoMemory().
This commit is contained in:
Serhiy Storchaka 2015-02-16 13:28:22 +02:00
parent e1efc07a30
commit 1a1ff29659
15 changed files with 50 additions and 52 deletions

View file

@ -3838,10 +3838,11 @@ static int _setup_ssl_threads(void) {
if (_ssl_locks == NULL) {
_ssl_locks_count = CRYPTO_num_locks();
_ssl_locks = (PyThread_type_lock *)
PyMem_Malloc(sizeof(PyThread_type_lock) * _ssl_locks_count);
if (_ssl_locks == NULL)
_ssl_locks = PyMem_New(PyThread_type_lock, _ssl_locks_count);
if (_ssl_locks == NULL) {
PyErr_NoMemory();
return 0;
}
memset(_ssl_locks, 0,
sizeof(PyThread_type_lock) * _ssl_locks_count);
for (i = 0; i < _ssl_locks_count; i++) {