Commit 4c28d2a
fix: prevent integer overflow in provide_at_least()
When available_clones.size() > n, the subtraction (n - available_clones.size())
caused unsigned arithmetic underflow, wrapping to INT_MAX (2^31-1). This made
the code try to allocate 2 billion clones, causing catastrophic memory growth.
The fix checks if we already have enough available clones before performing
the arithmetic. This prevents the underflow and keeps memory usage reasonable.
Before: decay_of_LD_highd.py would hit 12GB after 5 generations
After: Completes all 250 generations with <1GB memory
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 450eb08 commit 4c28d2a
1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
215 | 219 | | |
216 | 220 | | |
217 | 221 | | |
| |||
0 commit comments