File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -555,6 +555,12 @@ def test_count_overflow(self):
555555 hugecount3 = '{}i{}q' .format (sys .maxsize // 4 , sys .maxsize // 8 )
556556 self .assertRaises (struct .error , struct .calcsize , hugecount3 )
557557
558+ hugecount4 = '{}?s' .format (sys .maxsize )
559+ self .assertRaises (struct .error , struct .calcsize , hugecount4 )
560+
561+ hugecount5 = '{}?p' .format (sys .maxsize )
562+ self .assertRaises (struct .error , struct .calcsize , hugecount5 )
563+
558564 def test_trailing_counter (self ):
559565 store = array .array ('b' , b' ' * 100 )
560566
Original file line number Diff line number Diff line change @@ -1676,7 +1676,13 @@ prepare_s(PyStructObject *self)
16761676
16771677 switch (c ) {
16781678 case 's' : _Py_FALLTHROUGH ;
1679- case 'p' : len ++ ; ncodes ++ ; break ;
1679+ case 'p' :
1680+ if (len == PY_SSIZE_T_MAX ) {
1681+ goto overflow ;
1682+ }
1683+ len ++ ;
1684+ ncodes ++ ;
1685+ break ;
16801686 case 'x' : break ;
16811687 default :
16821688 if (num > PY_SSIZE_T_MAX - len ) {
You can’t perform that action at this time.
0 commit comments