File tree 2 files changed +11
-0
lines changed
2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1297,6 +1297,10 @@ def test_bool_na_values(self):
1297
1297
1298
1298
tm .assert_frame_equal (result , expected )
1299
1299
1300
+ def test_nonexistent_path (self ):
1301
+ # don't segfault pls #2428
1302
+ path = '%s.csv' % tm .rands (10 )
1303
+ self .assertRaises (Exception , self .read_csv , path )
1300
1304
1301
1305
class TestPythonParser (ParserTests , unittest .TestCase ):
1302
1306
Original file line number Diff line number Diff line change 8
8
void * new_file_source (char * fname , size_t buffer_size ) {
9
9
file_source * fs = (file_source * ) malloc (sizeof (file_source ));
10
10
fs -> fp = fopen (fname , "rb" );
11
+
12
+ if (fs -> fp == NULL ) {
13
+ free (fs );
14
+ return NULL ;
15
+ }
11
16
setbuf (fs -> fp , NULL );
12
17
13
18
fs -> initial_file_pos = ftell (fs -> fp );
@@ -59,6 +64,8 @@ void* new_rd_source(PyObject *obj) {
59
64
60
65
int del_file_source (void * fs ) {
61
66
// fseek(FS(fs)->fp, FS(fs)->initial_file_pos, SEEK_SET);
67
+ if (fs == NULL )
68
+ return 0 ;
62
69
63
70
/* allocated on the heap */
64
71
free (FS (fs )-> buffer );
You can’t perform that action at this time.
0 commit comments