# UNDF: UNDF-2026-000000004 Fixes angelscript-0003: CompileSwitch — caseValues.IndexOf() O(n) inside while loop over switch cases. Duplicate detection is O(n²) for switch statements. --- a/source/as_compiler.cpp +++ b/source/as_compiler.cpp @@ -4020,6 +4020,7 @@ void asCCompiler::CompileSwitch(...) asCArray caseValues; asCArray caseLabels; + asCSet caseValueSet; // FIX angelscript-0003: O(1) dup check — CWE-407 // Compile all case comparisons and make them jump to the right label asCScriptNode *cnode = snode->firstChild->next; while( cnode ) { // ... - // Has this case been declared already? - if (caseValues.IndexOf(c.type.GetConstantDW()) >= 0) // O(n) — CWE-407 + // Has this case been declared already? + if (caseValueSet.Exists(c.type.GetConstantDW())) // O(1) — fixed Error(TXT_DUPLICATE_SWITCH_CASE, cnode->firstChild); // Store constant for later use caseValues.PushLast(c.type.GetConstantDW()); + caseValueSet.Insert(c.type.GetConstantDW());