#127184 – Fix #127054: crash due to integer overflow in Resample Curves node – blender
This adds a variant of accumulate_counts_to_offsets which checks for overflows. The hot loop stays essentially the same, it just uses a int64_t instead of int for the counter now. For now the error state is returned by using an std::optional. Alternatives could be to throw std::overflow_error or to use some Result/Expected type in the future.
Obviously, there are more places that should handle this kind of error. It’s also not obvious how to propagate that error further up yet so that we can display e.g. a warning in the node. That decision should be applicable to other nodes too. For now, there is no warning on the node.
This adds a variant of `accumulate_counts_to_offsets` which checks for overflows. The hot loop stays essentially the same, it just uses a `int64_t` instead of `int` for the counter now. For now the error state is returned by using an `std::optional`. Alternatives could be to throw `std::overflow_error` or to use some [Result/Expected](https://devtalk.blender.org/t/developer-discussion-handling-errors/33054) type in the future.
Obviously, there are more places that should handle this kind of error. It’s also not obvious how to propagate that error further up yet so that we can display e.g. a warning in the node. That decision should be applicable to other nodes too. For now, there is no warning on the node.
Read more here: Source link
