From 998b407b2ab95c44c45761c8b2768c274ca6515f Mon Sep 17 00:00:00 2001 From: Matt Schatz Date: Tue, 24 Mar 2020 11:50:14 -0600 Subject: Fix the signed-ness within ConvToNum char overloads. It should be signed int with signed char and vice-versa. Currently, anything over 127 as unsigned char would return 0. --- include/convto.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/convto.h b/include/convto.h index 9ace83261..1fc684829 100644 --- a/include/convto.h +++ b/include/convto.h @@ -104,14 +104,14 @@ template<> inline char ConvToNum(const std::string& in) { // We specialise ConvToNum for char to avoid istringstream treating // the input as a character literal. - uint16_t num = ConvToNum(in); - return num <= UINT8_MAX ? num : 0; + int16_t num = ConvToNum(in); + return num >= INT8_MIN && num <= INT8_MAX ? num : 0; } template<> inline unsigned char ConvToNum(const std::string& in) { // We specialise ConvToNum for unsigned char to avoid istringstream // treating the input as a character literal. - int16_t num = ConvToNum(in); - return num >= INT8_MIN && num <= INT8_MAX ? num : 0; + uint16_t num = ConvToNum(in); + return num <= UINT8_MAX ? num : 0; } -- cgit v1.2.3