libluna: Do not fault if vstring_format() is called with buf=nullptr
Instead, just discard the output and return the number of bytes formatted, as mandated by the C standard.
This commit is contained in:
parent
ae01a31104
commit
0b553cadc0
@ -503,15 +503,18 @@ usize vstring_format(char* buf, usize max, const char* format, va_list ap)
|
||||
[](char c, void* arg) -> Result<void> {
|
||||
StringFormatInfo* info_arg = (StringFormatInfo*)arg;
|
||||
if (!info_arg->remaining) return {};
|
||||
*(info_arg->buffer) = c;
|
||||
info_arg->buffer++;
|
||||
if (info_arg->buffer)
|
||||
{
|
||||
*(info_arg->buffer) = c;
|
||||
info_arg->buffer++;
|
||||
}
|
||||
info_arg->remaining--;
|
||||
return {};
|
||||
},
|
||||
&info, ap)
|
||||
.value();
|
||||
|
||||
*(info.buffer) = 0;
|
||||
if (info.buffer) *(info.buffer) = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user