Closed Zbizu closed 1 day ago
You are correct, every division must ensure that the value is not divided by zero, as this results in undefined behavior in C++ and can cause program crashes. To address this, I recommend adding a check to ensure the divisor is not zero before performing the division. If you'd like, you could open a pull request with this fix to help improve the project.
Priority
Low
Area
What happened?
Summary
I just discovered a very old bug that is present in ALL tfs-based engines, which means that Canary could be affected too a little fun fact: OTServ doesn't have this bug (it was fixed somewhere around 2012 or earlier)
Steps to reproduce
Observed result
division by zero (server crash)
note: this screenshot was taken while debugging my own engine, but I've checked your code and it seems to have same bug
Line causing this
https://github.com/opentibiabr/canary/blob/main/src/creatures/combat/condition.cpp#L2508
possibly also: https://github.com/opentibiabr/canary/blob/main/src/creatures/combat/condition.cpp#L2543
Solution
set minimum light level to 1 in the line I linked
What OS are you seeing the problem on?
Linux
Code of Conduct