From: Miquel G. <gbm...@gm...> - 2010-11-09 23:03:30
|
--- Origin610Parser.cpp | 8 ++++++++ Origin700Parser.cpp | 5 +++++ Origin800Parser.cpp | 8 ++++++++ 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/Origin610Parser.cpp b/Origin610Parser.cpp index ddacd8f..2b83d58 100644 --- a/Origin610Parser.cpp +++ b/Origin610Parser.cpp @@ -436,6 +436,11 @@ bool Origin610Parser::parse() } readNotes(); + // If file has no Note windows, last function will read to EOF, + // skipping the info for ResultsLog and ProjectTree. + // As we know there is always a ResultsLog window after the Note + // windows, we better rewind to the start of Notes + file.seekg(POS, ios_base::beg); readResultsLog(); file.seekg(1 + 4*5 + 0x10 + 1, ios_base::cur); @@ -454,6 +459,9 @@ bool Origin610Parser::parse() void Origin610Parser::readNotes() { unsigned int pos = findStringPos("@"); + // if we are at end of file don't try to read a Note + if (!(pos < d_file_size)) + return; file.seekg(pos, ios_base::beg); unsigned int sectionSize; diff --git a/Origin700Parser.cpp b/Origin700Parser.cpp index 8f70ed0..029e8ca 100644 --- a/Origin700Parser.cpp +++ b/Origin700Parser.cpp @@ -419,6 +419,11 @@ bool Origin700Parser::parse() } readNotes(); + // If file has no Note windows, last function will read to EOF, + // skipping the info for ResultsLog and ProjectTree. + // As we know there is always a ResultsLog window after the Note + // windows, we better rewind to the start of Notes + file.seekg(POS, ios_base::beg); readResultsLog(); file.seekg(1 + 4*5 + 0x10 + 1, ios_base::cur); diff --git a/Origin800Parser.cpp b/Origin800Parser.cpp index 6dfed47..374e0a3 100644 --- a/Origin800Parser.cpp +++ b/Origin800Parser.cpp @@ -447,6 +447,11 @@ bool Origin800Parser::parse() } readNotes(); + // If file has no Note windows, last function will read to EOF, + // skipping the info for ResultsLog and ProjectTree. + // As we know there is always a ResultsLog window after the Note + // windows, we better rewind to the start of Notes + file.seekg(POS, ios_base::beg); readResultsLog(); file.seekg(1 + 4*5 + 0x10 + 1, ios_base::cur); @@ -465,6 +470,9 @@ bool Origin800Parser::parse() void Origin800Parser::readNotes() { unsigned int pos = findStringPos(notes_pos_mark); + // if we are at end of file don't try to read a Note + if (!(pos < d_file_size)) + return; file.seekg(pos, ios_base::beg); unsigned int sectionSize; -- 1.7.3 |