Cataclysm-DDA icon indicating copy to clipboard operation
Cataclysm-DDA copied to clipboard

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

Open megumin9 opened this issue 1 year ago • 2 comments

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

megumin9 avatar May 30 '24 04:05 megumin9

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.

github-actions[bot] avatar Jun 29 '24 14:06 github-actions[bot]

I have encountered and fixed this there:

  • #74343

Closing as solved

Brambor avatar Jun 30 '24 17:06 Brambor

Oh, I didn't close this as promised.

Brambor avatar Jul 22 '24 08:07 Brambor