diff options
author | Rusty Conover <rusty@conover.me> | 2020-01-26 10:53:26 -0500 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-01-28 19:54:43 -0800 |
commit | 32f63fcf0ed3b89aa8db672d73f387ee28468ba2 (patch) | |
tree | 59c33cbdea7f3b1ed278ff8611df3b1458cc6077 /src/debug_utils-inl.h | |
parent | 2462a2c5d7b5ae7e28a0fdefdf4fd5e8eb0ff5ed (diff) | |
download | node-new-32f63fcf0ed3b89aa8db672d73f387ee28468ba2.tar.gz |
src: fix debug crash handling null strings
When internal debug is enabled, output null strings as
"(null)" rather than crashing, matching glibc's behavior.
PR-URL: https://github.com/nodejs/node/pull/31523
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/debug_utils-inl.h')
-rw-r--r-- | src/debug_utils-inl.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/debug_utils-inl.h b/src/debug_utils-inl.h index f24643fbae..2f6137700d 100644 --- a/src/debug_utils-inl.h +++ b/src/debug_utils-inl.h @@ -21,7 +21,9 @@ struct ToStringHelper { enable_if<std::is_arithmetic<T>::value, bool>::type, typename dummy = bool> static std::string Convert(const T& value) { return std::to_string(value); } - static std::string Convert(const char* value) { return value; } + static std::string Convert(const char* value) { + 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"; } }; |