mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
GH-98897: fix memory leak if math.dist raises exception (GH-98898)
(cherry picked from commit ab57505070)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
d3d1738acd
commit
078ce6891c
3 changed files with 9 additions and 3 deletions
|
|
@ -2658,13 +2658,13 @@ math_dist_impl(PyObject *module, PyObject *p, PyObject *q)
|
|||
if (m != n) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"both points must have the same number of dimensions");
|
||||
return NULL;
|
||||
|
||||
goto error_exit;
|
||||
}
|
||||
if (n > NUM_STACK_ELEMS) {
|
||||
diffs = (double *) PyObject_Malloc(n * sizeof(double));
|
||||
if (diffs == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
PyErr_NoMemory();
|
||||
goto error_exit;
|
||||
}
|
||||
}
|
||||
for (i=0 ; i<n ; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue