Commit d3b1c7bb by Fergus Henderson Committed by Copybara-Service

Guard against null pointer dereference in DumpNode.

PiperOrigin-RevId: 628134930
Change-Id: I6b9763f2a87a9259963f00815c6953927f8add73
parent 8a3ae1b6
...@@ -75,7 +75,7 @@ using ::absl::cord_internal::kMinFlatLength; ...@@ -75,7 +75,7 @@ using ::absl::cord_internal::kMinFlatLength;
using ::absl::cord_internal::kInlinedVectorSize; using ::absl::cord_internal::kInlinedVectorSize;
using ::absl::cord_internal::kMaxBytesToCopy; using ::absl::cord_internal::kMaxBytesToCopy;
static void DumpNode(absl::Nonnull<CordRep*> rep, bool include_data, static void DumpNode(absl::Nonnull<CordRep*> nonnull_rep, bool include_data,
absl::Nonnull<std::ostream*> os, int indent = 0); absl::Nonnull<std::ostream*> os, int indent = 0);
static bool VerifyNode(absl::Nonnull<CordRep*> root, static bool VerifyNode(absl::Nonnull<CordRep*> root,
absl::Nonnull<CordRep*> start_node); absl::Nonnull<CordRep*> start_node);
...@@ -1457,12 +1457,13 @@ absl::string_view Cord::FlattenSlowPath() { ...@@ -1457,12 +1457,13 @@ absl::string_view Cord::FlattenSlowPath() {
} }
} }
static void DumpNode(absl::Nonnull<CordRep*> rep, bool include_data, static void DumpNode(absl::Nonnull<CordRep*> nonnull_rep, bool include_data,
absl::Nonnull<std::ostream*> os, int indent) { absl::Nonnull<std::ostream*> os, int indent) {
CordRep* rep = nonnull_rep;
const int kIndentStep = 1; const int kIndentStep = 1;
for (;;) { for (;;) {
*os << std::setw(3) << rep->refcount.Get(); *os << std::setw(3) << (rep == nullptr ? 0 : rep->refcount.Get());
*os << " " << std::setw(7) << rep->length; *os << " " << std::setw(7) << (rep == nullptr ? 0 : rep->length);
*os << " ["; *os << " [";
if (include_data) *os << static_cast<void*>(rep); if (include_data) *os << static_cast<void*>(rep);
*os << "]"; *os << "]";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment