diff options
author | David Tardon <dtardon@redhat.com> | 2021-05-30 13:03:28 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2021-05-31 15:35:07 +0200 |
commit | 95b8a091ad5f5b455b6fc473dfb0f57b72117801 (patch) | |
tree | d7d2cf8f4606917abd7f34c8ca7255fb21e40a44 | |
parent | 1a09ab0f0de35cbf287fbf96cd5f3b8498fcf3ce (diff) |
Stop parsing when an unknown record is encountered
The current code just emits a debug message and continues with the next
record, which is parsed at the same position as the skipped record,
therefore it's almost certain that the result of parsing it--and all the
following records--is going to be garbage. IMHO it's better to stop right
away and hope that enough has been parsed to produce a meaningful output.
Change-Id: I07a5e45950ac3243b99a049b782f45a027fbeb18
-rw-r--r-- | src/lib/FHParser.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/FHParser.cpp b/src/lib/FHParser.cpp index b9a09c0..72f6666 100644 --- a/src/lib/FHParser.cpp +++ b/src/lib/FHParser.cpp @@ -538,6 +538,11 @@ void libfreehand::FHParser::parseRecords(librevenge::RVNGInputStream *input, lib std::map<unsigned short, int>::const_iterator iterDict = m_dictionary.find(m_records[m_currentRecord]); if (iterDict != m_dictionary.end()) { + if (iterDict->second == FH_TOKEN_INVALID) + { + FH_DEBUG_MSG(("FHParser::parseRecords UNKNOWN TOKEN\n")); + return; + } parseRecord(input, collector, iterDict->second); } else |