fix possible overflow in encode_basestring_ascii (closes #23369)

This commit is contained in:
Benjamin Peterson 2015-02-01 17:53:53 -05:00
parent 4dbc305002
commit e3bfe19358
3 changed files with 25 additions and 5 deletions

View file

@ -1,5 +1,6 @@
from collections import OrderedDict
from test.test_json import PyTest, CTest
from test.support import bigaddrspacetest
CASES = [
@ -41,4 +42,10 @@ class TestEncodeBasestringAscii:
class TestPyEncodeBasestringAscii(TestEncodeBasestringAscii, PyTest): pass
class TestCEncodeBasestringAscii(TestEncodeBasestringAscii, CTest): pass
class TestCEncodeBasestringAscii(TestEncodeBasestringAscii, CTest):
@bigaddrspacetest
def test_overflow(self):
s = "\uffff"*((2**32)//6 + 1)
with self.assertRaises(OverflowError):
self.json.encoder.encode_basestring_ascii(s)