Skip to content

[Player] guard malformed time_to expression parsing#11462

Open
Harmenszoon wants to merge 2 commits into
simulationcraft:midnightfrom
Harmenszoon:codex/fix-time-to-expression-guard
Open

[Player] guard malformed time_to expression parsing#11462
Harmenszoon wants to merge 2 commits into
simulationcraft:midnightfrom
Harmenszoon:codex/fix-time-to-expression-guard

Conversation

@Harmenszoon
Copy link
Copy Markdown
Contributor

@Harmenszoon Harmenszoon commented May 11, 2026

Summary

  • Guard malformed global time_to_ player expressions before reading the third split segment
  • Guard malformed resource time_to_ expressions such as fury.time_to_ before reading the third split segment
  • Convert both cases from undefined behavior into normal APL parse errors

Cause

player_t::create_expression() accepts any expression prefixed with time_to_, splits it on _, then reads parts[2]. Because util::string_split() skips empty entries, the literal time_to_ produces only {time, to}, so the old code read past the end of the vector.

player_t::create_resource_expression() had the same shape for resource expressions. A malformed resource expression like fury.time_to_ also split to only {time, to} before the parser read parts[2].

Validation

  • Rebuilt Release build-fast with MSVC 14.44 / Ninja through VsDevCmd.bat
  • Before global fix: build-baseline/simc.exe profiles/MID1/MID1_Demon_Hunter_Havoc.simc actions=/wait,sec=time_to_ iterations=1 target_error=0 cleanup_threads=1 produced Invalid expression 'time_to_': bad allocation
  • After global fix: build-fast/simc.exe profiles/MID1/MID1_Demon_Hunter_Havoc.simc actions=/wait,sec=time_to_ iterations=1 target_error=0 cleanup_threads=1 reports Invalid 'time_to_' expression 'time_to_'.
  • Before resource fix: build-baseline/simc.exe profiles/MID1/MID1_Demon_Hunter_Havoc.simc actions=/wait,sec=fury.time_to_ iterations=1 target_error=0 cleanup_threads=1 produced Invalid expression 'fury.time_to_': string too long
  • After resource fix: build-fast/simc.exe profiles/MID1/MID1_Demon_Hunter_Havoc.simc actions=/wait,sec=fury.time_to_ iterations=1 target_error=0 cleanup_threads=1 reports Invalid resource expression 'fury.time_to_'.
  • Control: build-fast/simc.exe profiles/MID1/MID1_Demon_Hunter_Havoc.simc actions=/wait,sec=time_to_pct_ iterations=1 target_error=0 cleanup_threads=1 still reports the existing No pct value given for 'time_to_pct_' expression. error
  • Controls: build-fast/simc.exe profiles/MID1/MID1_Demon_Hunter_Havoc.simc actions+=/wait,sec=fury.time_to_max iterations=1 target_error=0 cleanup_threads=1 output=NUL and actions+=/wait,sec=fury.time_to_80 ... output=NUL both exit 0
  • Smoke: build-fast/simc.exe profiles/CI.simc iterations=10 target_error=0 cleanup_threads=1 output=NUL exits 0 with existing baseline warnings

Risk

Low. Valid time_to_die, time_to_pct_*, and <resource>.time_to_* expressions still have at least three split segments and continue through the existing parser paths.

@Harmenszoon Harmenszoon changed the title [Player] guard malformed time_to expressions [Player] guard malformed time_to expression parsing May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant