-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent item::charges_per_weight to return overflowed values #79422
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…into fix-aim-weight
…ysm-DDA into fix-aim-weight
The approach seems reasonable. Assuming tests pass I like the solution.
You could theoretically break up AIM's functions enough to make a test for it. That would probably be a large-ish refactoring though, so not in scope. If you're interested and need to know more, I am happy to explain. (Also it looks like you re-used the branch for your last PR? Not sure if that was intentional. Just FYI) |
yup, not intentional, thats why I rebased |
Summary
Bugfixes "Prevent item::charges_per_weight to return overflowed values"
Purpose of change
fix #79414
item::charges_per_weight and item::charges_per_volume didnt have any overflow protection. Thus, wen trying to put an item on the ground with AIM (practically infinite weight capacity) item::charges_per_weight would try to return a number greater then INT_MAX.
Describe the solution
partially rewrite item::charges_per_weight to de-duplicate code and return min(items, INFINITE_CHARGES ).
Describe alternatives you've considered
return int64_t instead of int
Testing
Can drop items again
Additional context
If only we could unittest AIM.