From: Georg Brandl Date: Tue, 5 May 2009 07:48:12 +0000 (+0000) Subject: #5932: fix error return in _convertPyInt_AsSsize_t() conversion function. X-Git-Tag: v2.7a1~1283 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f71ba95e9146872200bbc474337b41b0b4d964de;p=thirdparty%2FPython%2Fcpython.git #5932: fix error return in _convertPyInt_AsSsize_t() conversion function. --- diff --git a/Lib/json/tests/test_scanstring.py b/Lib/json/tests/test_scanstring.py index 6b600dbe16b5..53d0b6696e33 100644 --- a/Lib/json/tests/test_scanstring.py +++ b/Lib/json/tests/test_scanstring.py @@ -107,3 +107,6 @@ class TestScanString(TestCase): "xxx") self.assertRaises(UnicodeDecodeError, json.encoder.encode_basestring_ascii, b"xx\xff") + + 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 0e3046948e21..cfe87087d7f3 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -143,9 +143,9 @@ _convertPyInt_AsSsize_t(PyObject *o, Py_ssize_t *size_ptr) { /* PyObject to Py_ssize_t converter */ *size_ptr = PyInt_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 *