Skip to content

Commit 218aead

Browse files
committed
debug: Fix crash handling null strings
When internal debug is enabled output null strings as "(null)" rather than crashing matching glibc's behavior.
1 parent d6f1e39 commit 218aead

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/debug_utils-inl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ struct ToStringHelper {
2121
enable_if<std::is_arithmetic<T>::value, bool>::type,
2222
typename dummy = bool>
2323
static std::string Convert(const T& value) { return std::to_string(value); }
24-
static std::string Convert(const char* value) { return value; }
24+
static std::string Convert(const char* value) {
25+
return value ? value : "(null)";
26+
}
2527
static std::string Convert(const std::string& value) { return value; }
2628
static std::string Convert(bool value) { return value ? "true" : "false"; }
2729
};

0 commit comments

Comments
 (0)