@@ -3667,6 +3667,25 @@ def test_buffer_overflow(self):
3667
3667
self .assertIn (
3668
3668
'Buffer overflow caught - possible malformed input file.' , str (cperr ))
3669
3669
3670
+ def test_buffer_rd_bytes (self ):
3671
+ # GH 12098
3672
+ # src->buffer can be freed twice leading to a segfault if a corrupt
3673
+ # gzip file is read with read_csv and the buffer is filled more than
3674
+ # once before gzip throws an exception
3675
+
3676
+ data = '\x1F \x8B \x08 \x00 \x00 \x00 \x00 \x00 \x00 \x03 \xED \xC3 \x41 \x09 ' \
3677
+ '\x00 \x00 \x08 \x00 \xB1 \xB7 \xB6 \xBA \xFE \xA5 \xCC \x21 \x6C \xB0 ' \
3678
+ '\xA6 \x4D ' + '\x55 ' * 267 + \
3679
+ '\x7D \xF7 \x00 \x91 \xE0 \x47 \x97 \x14 \x38 \x04 \x00 ' \
3680
+ '\x1f \x8b \x08 \x00 VT\x97 V\x00 \x03 \xed ]\xef O'
3681
+ for i in range (100 ):
3682
+ try :
3683
+ _ = self .read_csv (StringIO (data ),
3684
+ compression = 'gzip' ,
3685
+ delim_whitespace = True )
3686
+ except Exception as e :
3687
+ pass
3688
+
3670
3689
def test_single_char_leading_whitespace (self ):
3671
3690
# GH 9710
3672
3691
data = """\
@@ -4208,6 +4227,25 @@ def test_buffer_overflow(self):
4208
4227
self .assertIn (
4209
4228
'Buffer overflow caught - possible malformed input file.' , str (cperr ))
4210
4229
4230
+ def test_buffer_rd_bytes (self ):
4231
+ # GH 12098
4232
+ # src->buffer can be freed twice leading to a segfault if a corrupt
4233
+ # gzip file is read with read_csv and the buffer is filled more than
4234
+ # once before gzip throws an exception
4235
+
4236
+ data = '\x1F \x8B \x08 \x00 \x00 \x00 \x00 \x00 \x00 \x03 \xED \xC3 \x41 \x09 ' \
4237
+ '\x00 \x00 \x08 \x00 \xB1 \xB7 \xB6 \xBA \xFE \xA5 \xCC \x21 \x6C \xB0 ' \
4238
+ '\xA6 \x4D ' + '\x55 ' * 267 + \
4239
+ '\x7D \xF7 \x00 \x91 \xE0 \x47 \x97 \x14 \x38 \x04 \x00 ' \
4240
+ '\x1f \x8b \x08 \x00 VT\x97 V\x00 \x03 \xed ]\xef O'
4241
+ for i in range (100 ):
4242
+ try :
4243
+ _ = self .read_csv (StringIO (data ),
4244
+ compression = 'gzip' ,
4245
+ delim_whitespace = True )
4246
+ except Exception as e :
4247
+ pass
4248
+
4211
4249
def test_single_char_leading_whitespace (self ):
4212
4250
# GH 9710
4213
4251
data = """\
0 commit comments