From a12ceb74dd61f73d152cdc6ec2ae7c9ea1d1df55 Mon Sep 17 00:00:00 2001 From: Mark Tucker Date: Mon, 20 Apr 2020 15:02:14 -0400 Subject: [PATCH] Make the SdfPathTable::_EraseSubtreeAndSiblings non-recursive, so there is no risk of running out of stack space even with an incredibly large number of siblings. --- pxr/usd/sdf/pathTable.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pxr/usd/sdf/pathTable.h b/pxr/usd/sdf/pathTable.h index 29b632cd95..6362f89839 100644 --- a/pxr/usd/sdf/pathTable.h +++ b/pxr/usd/sdf/pathTable.h @@ -631,9 +631,13 @@ class SdfPathTable _EraseSubtree(entry); // And siblings. - if (_Entry * const nextSibling = entry->GetNextSibling()) { - _EraseSubtreeAndSiblings(nextSibling); - _EraseFromTable(nextSibling); + _Entry *sibling = entry->GetNextSibling(); + _Entry *nextSibling = sibling ? sibling->GetNextSibling() : nullptr; + while (sibling) { + _EraseSubtree(sibling); + _EraseFromTable(sibling); + sibling = nextSibling; + nextSibling = sibling ? sibling->GetNextSibling() : nullptr; } }