Ensure that node pointer is valid before traversing.

This commit is contained in:
Rene Gollent
2012-12-11 22:56:46 -05:00
parent 8f06ba2f84
commit 9403439347
@@ -197,8 +197,6 @@ UiUtils::PrintValueNodeGraph(BString& _output, StackFrame* frame,
return; return;
} }
_output << " {\n";
if (node->CountChildren() == 1 if (node->CountChildren() == 1
&& node->GetType()->Kind() == TYPE_ADDRESS && node->GetType()->Kind() == TYPE_ADDRESS
&& node->ChildAt(0)->GetType()->Kind() == TYPE_COMPOUND) { && node->ChildAt(0)->GetType()->Kind() == TYPE_COMPOUND) {
@@ -208,18 +206,22 @@ UiUtils::PrintValueNodeGraph(BString& _output, StackFrame* frame,
node = node->ChildAt(0)->Node(); node = node->ChildAt(0)->Node();
} }
for (int32 i = 0; i < node->CountChildren(); i++) { if (node != NULL) {
// don't dump compound nodes if our depth limit won't allow _output << " {\n";
// us to traverse into their children anyways, and the top
// level node contains no data of intereest. for (int32 i = 0; i < node->CountChildren(); i++) {
if (node->ChildAt(i)->GetType()->Kind() != TYPE_COMPOUND // don't dump compound nodes if our depth limit won't allow
|| maxDepth > 1) { // us to traverse into their children anyways, and the top
PrintValueNodeGraph(_output, frame, node->ChildAt(i), // level node contains no data of intereest.
indentLevel + 1, maxDepth - 1); if (node->ChildAt(i)->GetType()->Kind() != TYPE_COMPOUND
|| maxDepth > 1) {
PrintValueNodeGraph(_output, frame, node->ChildAt(i),
indentLevel + 1, maxDepth - 1);
}
} }
_output.Append('\t', indentLevel);
_output << "}\n";
} }
_output.Append('\t', indentLevel);
_output << "}\n";
return; return;
} }