Fix stringToOEM and stringToPSM

Remove debug output and fix an out-of-bounds read for unsupported arguments.

Fixes: e8a9a56f9f ("Support symbolic values for --oem and --psm options")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2024-11-10 10:13:19 +01:00
parent 49cbe2b47d
commit e83f78020e

View File

@ -351,8 +351,7 @@ static int stringToOEM(const std::string arg) {
{"default", 3}, {"default", 3},
}; };
auto it = oem_map.find(arg); auto it = oem_map.find(arg);
printf("it: %d, %d\n", it == oem_map.end(), it->second); return it == oem_map.end() ? -1 : it->second;
return it->second;
} }
static int stringToPSM(const std::string arg) { static int stringToPSM(const std::string arg) {
@ -387,7 +386,7 @@ static int stringToPSM(const std::string arg) {
{"raw_line", 13}, {"raw_line", 13},
}; };
auto it = psm_map.find(arg); 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 // NOTE: arg_i is used here to avoid ugly *i so many times in this function