diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-20 18:12:48 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-08-20 18:12:48 +0300 |
commit | efafe7474ddfc993b63524983e6d8de7f86feae5 (patch) | |
tree | 255542a48502b4d000b91f35037150ac5f2b2138 /source | |
parent | 31fc76fa5b42b1b4d303cc3eb256c44b3da60f36 (diff) |
Compositor: Fix dilare erode reading input out of bounds
Happened when output area was partial horizontally, for example
when using a viewer border.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/compositor/operations/COM_DilateErodeOperation.cc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cc b/source/blender/compositor/operations/COM_DilateErodeOperation.cc index 1a413257f00..cf59872165d 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cc +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cc @@ -723,11 +723,9 @@ static void step_update_memory_buffer(MemoryBuffer *output, const int bwidth = area.xmax - area.xmin; const int bheight = area.ymax - area.ymin; - /* NOTE: #result has area width, but new height. - * We have to calculate the additional rows in the first pass, - * to have valid data available for the second pass. */ + /* Create a buffer with the area needed for horizontal and vertical passes. */ rcti result_area; - BLI_rcti_init(&result_area, area.xmin, area.xmax, ymin, ymax); + BLI_rcti_init(&result_area, xmin, xmax, ymin, ymax); MemoryBuffer result(DataType::Value, result_area); /* #temp holds maxima for every step in the algorithm, #buf holds a @@ -764,12 +762,12 @@ static void step_update_memory_buffer(MemoryBuffer *output, } /* Second pass, vertical dilate/erode. */ - for (int x = 0; x < bwidth; x++) { + for (int x = xmin; x < xmax; x++) { for (int y = 0; y < bheight + 5 * half_window; y++) { buf[y] = compare_min_value; } for (int y = ymin; y < ymax; y++) { - buf[y - area.ymin + window - 1] = result.get_value(x + area.xmin, y, 0); + buf[y - area.ymin + window - 1] = result.get_value(x, y, 0); } for (int i = 0; i < (bheight + 3 * half_window) / window; i++) { |