mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015)
Set MemoryError when appropriate, add missing failure checks, and fix some potential leaks.
This commit is contained in:
parent
3a521f0b61
commit
4c49da0cb7
17 changed files with 113 additions and 27 deletions
|
|
@ -2142,7 +2142,7 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q)
|
|||
if (n > NUM_STACK_ELEMS) {
|
||||
diffs = (double *) PyObject_Malloc(n * sizeof(double));
|
||||
if (diffs == NULL) {
|
||||
return NULL;
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
}
|
||||
for (i=0 ; i<n ; i++) {
|
||||
|
|
@ -2199,8 +2199,9 @@ math_hypot(PyObject *self, PyObject *args)
|
|||
n = PyTuple_GET_SIZE(args);
|
||||
if (n > NUM_STACK_ELEMS) {
|
||||
coordinates = (double *) PyObject_Malloc(n * sizeof(double));
|
||||
if (coordinates == NULL)
|
||||
return NULL;
|
||||
if (coordinates == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
}
|
||||
for (i=0 ; i<n ; i++) {
|
||||
item = PyTuple_GET_ITEM(args, i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue