From e83f78020e37f6d291b9967f43c5ecf5ff092952 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sun, 10 Nov 2024 10:13:19 +0100 Subject: [PATCH] Fix stringToOEM and stringToPSM Remove debug output and fix an out-of-bounds read for unsupported arguments. Fixes: e8a9a56f9fdb ("Support symbolic values for --oem and --psm options") Signed-off-by: Stefan Weil --- src/tesseract.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tesseract.cpp b/src/tesseract.cpp index 4558ca388a..2c27d2a04f 100644 --- a/src/tesseract.cpp +++ b/src/tesseract.cpp @@ -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) { @@ -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