From f5e84b6e37f9c78dc8ea6e24e1186f9146b4aa3b Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Sat, 17 May 2025 10:26:15 -0500 Subject: [PATCH] dialogxml catch nonexistent anchor at end of relative chain --- src/dialogxml/dialogs/dialog.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 97bd174f..917b179b 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -283,8 +283,12 @@ void cDialog::loadFromFile(const DialogDefn& file){ // Make sure it's not a loop! std::vector refs{ctrl.anchor}; while(!anchor->anchor.empty()) { + cControl* next_anchor = findControl(anchor->anchor); + if(next_anchor == nullptr){ + throw xBadVal(ctrlTypeName(anchor->getType()), "anchor", anchor->anchor, 0, 0, fname); + } refs.push_back(anchor->anchor); - anchor = findControl(anchor->anchor); + anchor = next_anchor; if(std::find(refs.begin(), refs.end(), anchor->anchor) != refs.end()) { throw xBadVal(ctrlTypeName(ctrl.getType()), "anchor", "", 0, 0, fname); }