Closed Brett208 closed 5 years ago
Do you remember the conversation where the above formula came from? I'd like to have a reference to the original discussion. I'm having trouble tracking down where we came up with:
if (scaleFactor > 0 && tileIndex > (std::numeric_limits<unsigned int>::max() - scaleFactor) / scaleFactor)
I vaguely remember it being something about a check done while pasting tiles, rather than when the tilesets were scaled.
Check this page for the comment in the code section. If it doesn't display for you, I'll paste in here:
Checks are run multiple times when forming an image for no reason. Check also doesn't handle possible wrap-around conditions if large enough values are multiplied. Thanks to Dan for doing the legwork identifying this problem.
Dimension checks should look something like:
https://stackoverflow.com/questions/1815367/catch-and-compute-overflow-during-multiplication-of-two-large-integers