Bud: The program may crush when the vector items_ is empty in file /src/options.cpp. (static analysis report)
Describe the bug
In file /src/options.cpp, line 1422. If the vector items_ is empty, iter ,equal to std::next( items_.begin() ), is behind items_.end(). The for loop may go wrong. Is it need to add a check here?
https://github.com/CleverRaven/Cataclysm-DDA/blob/856ea9d50e858ba991fe574360ac989de0cffbfe/src/options.cpp#L1416-L1428
Attach save file
N/A
Steps to reproduce
N/A
Expected behavior
N/A
Screenshots
No response
Versions and configuration
Our static analyzer checks commit 77ff212, but the same issue still exists in the latest version on the default branch.
Additional context
No response
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.
I have encountered and fixed this there:
- #74343
Closing as solved
Oh, I didn't close this as promised.