fixing UB

This commit is contained in:
bogdasar1985 2020-05-28 19:13:55 +05:00 committed by Martin Hořeňovský
parent b1b5cb8122
commit 6c6ebe374a
3 changed files with 3 additions and 3 deletions

View File

@ -667,7 +667,7 @@ namespace detail {
} }
inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { inline auto convertInto( std::string const &source, bool &target ) -> ParserResult {
std::string srcLC = source; std::string srcLC = source;
std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( std::tolower(c) ); } ); std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower(c) ); } );
if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on")
target = true; target = true;
else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off")

View File

@ -18,7 +18,7 @@ namespace Catch {
namespace { namespace {
char toLowerCh(char c) { char toLowerCh(char c) {
return static_cast<char>( std::tolower( c ) ); return static_cast<char>( std::tolower( static_cast<unsigned char>(c) ) );
} }
} }

View File

@ -667,7 +667,7 @@ namespace detail {
} }
inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { inline auto convertInto( std::string const &source, bool &target ) -> ParserResult {
std::string srcLC = source; std::string srcLC = source;
std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( ::tolower(c) ); } ); std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast<char>( ::tolower( c ) ); } );
if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on")
target = true; target = true;
else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off")