mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-20 14:08:20 +00:00
Avoid signed-shift undefined behavior in EdgeGrid distance propagation (#16626)
Danielsson propagation in EdgeGrid::Grid::calculate_sdf() doubles a negative neighbor offset (-1 or -ncols) with a left shift, which is undefined behavior in C++17. Multiply by two instead. Adds test_edge_grid.cpp, which checks signed distances inside and outside a rectangle beyond the initial edge band. Built with -fsanitize=shift, it aborts on the old code and passes with the fix.
This commit is contained in:
3 files changed
+35
-1
No files matched your search
@@ -616,7 +616,7 @@ struct PropagateDanielssonSingleStep {
|
||||
if ((signs[addr] & 2) == 0) {
|
||||
float *v = &L[addr << 1];
|
||||
float l = v[0] * v[0] + v[1] * v[1];
|
||||
float *v2s = v + (addr_delta << 1);
|
||||
float *v2s = v + 2 * addr_delta;
|
||||
float v2[2] = {
|
||||
v2s[0] + INCX * resolution,
|
||||
v2s[1] + INCY * resolution
|
||||
|
||||
Reference in new issue
Block a user