feature (string utils): replacing NULL reference strings in format with warning

This commit is contained in:
antifallobst 2023-03-11 11:23:53 +01:00
parent b89c2fba83
commit a6af38bb39
1 changed files with 10 additions and 2 deletions

View File

@ -71,7 +71,12 @@ uint64_t variadic_format_size(string_t string, va_list args) {
}
case 's': {
// string
uint64_t strlen = string_length(va_arg(args, string_t));
string_t str = va_arg(args, string_t);
if (str == NULL) {
str = "<string NULL reference>";
}
uint64_t strlen = string_length(str);
if (numeric_specifier > 0) {
strlen = MIN(strlen, numeric_specifier);
}
@ -202,6 +207,9 @@ void variadic_format(string_t output, string_t string, va_list args) {
case 's': {
// string
string_t str = va_arg(args, string_t);
if (str == NULL) {
str = "<string NULL reference>";
}
uint64_t strlen = string_length(str);
if (numeric_specifier > 0) {