read_csv crashes when reading a csv file with only one column (Bug #1981)
Description
The function read_csv
crashes when reading data who only has one column.
Here is the code:
1// read the first line and determine the number of variables
2std::vector<char> _buf(M);
3char* buf = &_buf[0];
4if( !fgets_chomp( buf, M, file ))
5{
6 fclose(file);
7 return -1;
8}
9for( ptr = buf; *ptr != '\0'; ptr++ )
10 cols_count += (*ptr == delimiter);
11
12if ( cols_count == 0)
13{
14 fclose(file);
15 return -1;
16}
17cols_count++;
If the values have no commas before the newline it crashes in if ( cols_count == 0)
if they have a comma before the newline it crashes when you use get_values()
(Access Violation).
Related issues
related to Bug #1: Inplace Mat::convertTo | Done |
History
Updated by Andrey Kamaev almost 13 years ago
- Description changed from The function read_csv crashes when reading data who only has one column. Her... to The function @read_csv@ crashes when reading data who only has one column. H... More
- Category set to ml
- Assignee set to Maria Dimashova
Updated by Maria Dimashova almost 13 years ago
Thank you for the reporting. The bug was fixed in r8450.
- Status changed from Open to Done
Updated by Andrey Kamaev almost 13 years ago
- Target version set to 2.4.1