CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
9.95k stars 4.08k forks source link

Bud: The program may crush when the vector items_ is empty in file /src/options.cpp. (static analysis report) #74184

Open megumin9 opened 1 month ago

megumin9 commented 1 month ago

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

github-actions[bot] commented 6 days ago

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.

Brambor commented 5 days ago

I have encountered and fixed this there:

Closing as solved