diff options
| author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-11-01 07:48:32 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-31 21:18:32 -0500 |
| commit | ab575050709e2b313ca9a9585f09b6f4b0560318 (patch) | |
| tree | ea50310d73da93ffad36bfeab28f760ed1926849 /Modules/mathmodule.c | |
| parent | 88297e2a8a75898228360ee369628a4a6111e2ee (diff) | |
| download | cpython-git-ab575050709e2b313ca9a9585f09b6f4b0560318.tar.gz | |
GH-98897: fix memory leak if `math.dist` raises exception (GH-98898)
Diffstat (limited to 'Modules/mathmodule.c')
| -rw-r--r-- | Modules/mathmodule.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 48625c8c18..46427876b8 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -2717,13 +2717,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++) { |
