diff --git a/Lib/json/tests/test_scanstring.py b/Lib/json/tests/test_scanstring.py index 2d55672b7ad..2e9136b08f9 100644 --- a/Lib/json/tests/test_scanstring.py +++ b/Lib/json/tests/test_scanstring.py @@ -102,3 +102,6 @@ class TestScanString(TestCase): self.assertEquals( scanstring('["Bad value", truth]', 2, True), ('Bad value', 12)) + + def test_overflow(self): + self.assertRaises(OverflowError, json.decoder.scanstring, b"xxx", sys.maxsize+1) diff --git a/Modules/_json.c b/Modules/_json.c index 45f4b58e41d..c44dbac1f13 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -133,9 +133,9 @@ _convertPyInt_AsSsize_t(PyObject *o, Py_ssize_t *size_ptr) { /* PyObject to Py_ssize_t converter */ *size_ptr = PyLong_AsSsize_t(o); - if (*size_ptr == -1 && PyErr_Occurred()); - return 1; - return 0; + if (*size_ptr == -1 && PyErr_Occurred()) + return 0; + return 1; } static PyObject *