Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: Fix crash handling null strings #31523

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add test and fix nit.
  • Loading branch information
rustyconover committed Jan 26, 2020
commit 6727bc0fcab49e226e074de391d56f23646915c6
2 changes: 1 addition & 1 deletion src/debug_utils-inl.h
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ struct ToStringHelper {
typename dummy = bool>
static std::string Convert(const T& value) { return std::to_string(value); }
static std::string Convert(const char* value) {
return value ? value : "(null)";
return value != nullptr ? value : "(null)";
}
static std::string Convert(const std::string& value) { return value; }
static std::string Convert(bool value) { return value ? "true" : "false"; }
1 change: 1 addition & 0 deletions test/cctest/test_util.cc
Original file line number Diff line number Diff line change
@@ -281,6 +281,7 @@ TEST(UtilTest, SPrintF) {
const char* bar = "bar";
EXPECT_EQ(SPrintF("%s %s", foo, "bar"), "foo bar");
EXPECT_EQ(SPrintF("%s %s", foo, bar), "foo bar");
EXPECT_EQ(SPrintF("%s", nullptr), "(null)");

EXPECT_EQ(SPrintF("[%% %s %%]", foo), "[% foo %]");