diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/format.hpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compat/format.hpp b/compat/format.hpp index 9a61dd96..741b35bd 100644 --- a/compat/format.hpp +++ b/compat/format.hpp @@ -1,4 +1,5 @@ #pragma once +#include "compat/assert.hpp" #include <fmt/core.h> #include <fmt/compile.h> #include <Corrade/Containers/StringView.h> @@ -54,6 +55,7 @@ size_t snformat(char(&buf)[N], Fmt&& fmt, Xs&&... args) constexpr size_t n = N > 0 ? N - 1 : 0; auto result = fmt::format_to_n(buf, n, Corrade::Utility::forward<Fmt>(fmt), Corrade::Utility::forward<Xs>(args)...); const auto len = Utility::min(n, result.size); + fm_assert(len > 0); if constexpr(N > 0) buf[len] = '\0'; return len; |