Add nullptr checks to char type logging

This commit is contained in:
Riyyi
2021-01-02 00:50:31 +01:00
parent 965005aaef
commit 198a61f054
+10
View File
@@ -9,12 +9,22 @@ namespace Inferno {
const LogStream& operator<<(const LogStream& stream, const char* value) const LogStream& operator<<(const LogStream& stream, const char* value)
{ {
if (value == nullptr) {
stream.write("(null)", 6);
return stream;
}
stream.write(value, strlen(value)); stream.write(value, strlen(value));
return stream; return stream;
} }
const LogStream& operator<<(const LogStream& stream, const unsigned char* value) const LogStream& operator<<(const LogStream& stream, const unsigned char* value)
{ {
if (value == nullptr) {
stream.write("(null)", 6);
return stream;
}
stream.write(value, strlen((const char*)value)); stream.write(value, strlen((const char*)value));
return stream; return stream;
} }