Throw an exception on invalid input in StringUtils::Utf8CharSizeAt()

1164-fix
suve 2020-07-05 13:08:39 +02:00 committed by Mateusz Przybył
parent 86ef158c00
commit e2eb5b91e0
1 changed files with 2 additions and 1 deletions

View File

@ -22,6 +22,7 @@
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#include <stdexcept>
#include <vector> #include <vector>
@ -183,7 +184,7 @@ int StrUtils::Utf8CharSizeAt(const std::string &str, unsigned int pos)
// Invalid char - unexpected continuation byte // Invalid char - unexpected continuation byte
if(c >= 0x80) if(c >= 0x80)
return 0; throw new std::invalid_argument("Unexpected UTF-8 continuation byte");
return 1; return 1;
} }