Commit fb3336ac authored by stratakis's avatar stratakis Committed by Victor Stinner

[2.7] bpo-36291: Fix a possible reference leak in the json module (GH-12330)

Fix a reference leak in json if parsing a floating point number fails.

If PyOS_string_to_double() fails in _match_number_str():
decrement numstr ref counter.
parent 2832ad53
Fix a possible reference leak in the json module.
......@@ -1375,8 +1375,10 @@ _match_number_str(PyScannerObject *s, PyObject *pystr, Py_ssize_t start, Py_ssiz
else {
double d = PyOS_string_to_double(PyString_AS_STRING(numstr),
NULL, NULL);
if (d == -1.0 && PyErr_Occurred())
if (d == -1.0 && PyErr_Occurred()) {
Py_DECREF(numstr);
return NULL;
}
rval = PyFloat_FromDouble(d);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment