Fix string_printf in case of error in formating.

This commit is contained in:
Patrick Pelissier committed 2020-11-05 22:51:28 +01:00
1 parent d92126b97e
commit b0a74f162e
1 file changed
+6 -2
+6 -2
View File
@@ -792,8 +792,12 @@ string_printf (string_t v, const char format[], ...)
size = vsnprintf (ptr, alloc, format, args);
M_ASSERT (size > 0 && (size_t)size < alloc);
}
if (size >= 0) {
if (M_LIKELY (size >= 0)) {
stringi_set_size(v, (size_t) size);
} else {
// An error occured during the conversion: Assign an empty string.
stringi_set_size(v, 0);
ptr[0] = 0;
}
va_end (args);
STRINGI_CONTRACT (v);
@@ -1411,7 +1415,7 @@ string_it(string_it_t it, const string_t str)
}
/* Set the iterator to the end of string
The iterator references therefore nothong.
The iterator references therefore nothing.
*/
static inline void
string_it_end(string_it_t it, const string_t str)