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

Bud: There may be some out-of-bound accesses in file src/iuse.cpp. (static analysis report)

Open megumin9 opened this issue 1 year ago • 1 comments

Describe the bug

In file src/iuse.cpp, there are some std::find_if() functions in line 2843, 2846, 2867, 2887 and 2907. I find the ranges of those find statement are all from cnstr.begin() to cnstr.end(). It is possible to return cnstr.end() if there is no element match the condition, and then the access to the result will be an out-of-bound access. Is it need to add a check here?

(https://github.com/CleverRaven/Cataclysm-DDA/blob/671a7083d463bc326bcef8355894aef6843900d8/src/iuse.cpp#L2843-L2850)

(https://github.com/CleverRaven/Cataclysm-DDA/blob/671a7083d463bc326bcef8355894aef6843900d8/src/iuse.cpp#L2867-L2871)

(https://github.com/CleverRaven/Cataclysm-DDA/blob/671a7083d463bc326bcef8355894aef6843900d8/src/iuse.cpp#L2887-L2891)

(https://github.com/CleverRaven/Cataclysm-DDA/blob/671a7083d463bc326bcef8355894aef6843900d8/src/iuse.cpp#L2907-L2911)

Attach save file

N/A

Steps to reproduce

N/A

Expected behavior

N/A

Screenshots

No response

Versions and configuration

The newest vertion 4c6b918.

Additional context

No response

megumin9 avatar May 30 '24 03: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 04:06 github-actions[bot]