read_csv crashes when reading a csv file with only one column (Bug #1981)


Added by Pau Bel almost 13 years ago. Updated almost 13 years ago.


Status:Done Start date:2012-05-24
Priority:Normal Due date:
Assignee:Maria Dimashova % Done:

0%

Category:ml
Target version:2.4.1
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

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

Associated revisions

Revision 276a3fe0
Added by Maria Dimashova almost 13 years ago

fixed #1981

Revision c9ed05c3
Added by Andrey Pavlenko about 11 years ago

Merge pull request #1981 from ilya-lavrenov:tapi_sqrt

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

Also available in: Atom PDF