diff options
author | B. Stack <bgstack15@gmail.com> | 2023-05-19 09:24:58 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2023-05-19 09:24:58 -0400 |
commit | 90bc692185a27f18acb6b029dfaf038e555ef8ff (patch) | |
tree | fdb56193bab28d36a4c6723bf847f3aa2ce36a9b /zen/string_tools.h | |
parent | add upstream 12.2 (diff) | |
download | FreeFileSync-12.3.tar.gz FreeFileSync-12.3.tar.bz2 FreeFileSync-12.3.zip |
add upstream 12.312.3
Diffstat (limited to 'zen/string_tools.h')
-rw-r--r-- | zen/string_tools.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/zen/string_tools.h b/zen/string_tools.h index 1cd8ef0d..3aa1c1d6 100644 --- a/zen/string_tools.h +++ b/zen/string_tools.h @@ -639,17 +639,17 @@ int saferPrintf(wchar_t* buffer, size_t bufferSize, const wchar_t* format, const template <class S, class T, class Num> inline S printNumber(const T& format, const Num& number) //format a single number using ::sprintf { -#ifdef __cpp_lib_format -#error refactor? -#endif static_assert(std::is_same_v<GetCharTypeT<S>, GetCharTypeT<T>>); assert(strBegin(format)[strLength(format)] == 0); //format must be null-terminated! S buf(128, static_cast<GetCharTypeT<S>>('0')); const int charsWritten = impl::saferPrintf(buf.data(), buf.size(), strBegin(format), number); - if (makeUnsigned(charsWritten) > buf.size()) + if (charsWritten < 0 || makeUnsigned(charsWritten) > buf.size()) + { + assert(false); return S(); + } buf.resize(charsWritten); return buf; |