Skip to content

Commit

Permalink
fix: matchParser is called more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
myzhan committed Oct 10, 2023
1 parent c5d8a32 commit 818d455
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/parser-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ class ParserManager: public IParserManager
if (!data)
return NULL;

size_t preVal = -1;
for (ParserList_t::const_iterator it = m_parsers.begin(); it != m_parsers.end(); ++it)
{
unsigned int myVal = (*it)->matchParser(fileName, data, sz);
if (myVal == match_none)
continue;

if (!best)
best = *it;

unsigned int bestVal = best->matchParser(fileName, data, sz);

if (myVal > bestVal)
if (!best || myVal > preVal) {
best = *it;
preVal = myVal;
}
}

free((void *) data);
Expand Down

0 comments on commit 818d455

Please sign in to comment.