summaryrefslogtreecommitdiff
path: root/AK/Format.h
diff options
context:
space:
mode:
Diffstat (limited to 'AK/Format.h')
-rw-r--r--AK/Format.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/AK/Format.h b/AK/Format.h
index ddd612968d..b9b69ca15b 100644
--- a/AK/Format.h
+++ b/AK/Format.h
@@ -395,6 +395,8 @@ template<>
struct Formatter<Bytes> : Formatter<ReadonlyBytes> {
};
+// FIXME: Printing raw char pointers is inherently dangerous. Remove this and
+// its users and prefer StringView over it.
template<>
struct Formatter<char const*> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, char const* value)
@@ -403,7 +405,8 @@ struct Formatter<char const*> : Formatter<StringView> {
Formatter<FlatPtr> formatter { *this };
return formatter.format(builder, reinterpret_cast<FlatPtr>(value));
}
- return Formatter<StringView>::format(builder, value);
+
+ return Formatter<StringView>::format(builder, value != nullptr ? StringView { value, __builtin_strlen(value) } : "(null)"sv);
}
};
template<>