Skip to content

Commit

Permalink
Fix stringToOEM and stringToPSM
Browse files Browse the repository at this point in the history
Remove debug output and fix an out-of-bounds read for unsupported arguments.

Fixes: e8a9a56 ("Support symbolic values for --oem and --psm options")
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Nov 10, 2024
1 parent 49cbe2b commit e83f780
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/tesseract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ static int stringToOEM(const std::string arg) {
{"default", 3},
};
auto it = oem_map.find(arg);
printf("it: %d, %d\n", it == oem_map.end(), it->second);
return it->second;
return it == oem_map.end() ? -1 : it->second;
}

static int stringToPSM(const std::string arg) {
Expand Down Expand Up @@ -387,7 +386,7 @@ static int stringToPSM(const std::string arg) {
{"raw_line", 13},
};
auto it = psm_map.find(arg);
return it->second;
return it == psm_map.end() ? -1 : it->second;
}

// NOTE: arg_i is used here to avoid ugly *i so many times in this function
Expand Down

0 comments on commit e83f780

Please sign in to comment.