diff options
author | Michele Di Giorgio <michele.digiorgio@arm.com> | 2018-06-29 11:17:18 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:53:57 +0000 |
commit | 89a2b571cfc0ea87c26ba8b1ed1ab87d13244f0e (patch) | |
tree | 95770655d9c44cfe32fc007671d602f1dc1dc6f9 /tests/validation/reference/CannyEdgeDetector.cpp | |
parent | 4622ac15aa009b3ce90ddc6c2ad6c918d6776103 (diff) | |
download | ComputeLibrary-89a2b571cfc0ea87c26ba8b1ed1ab87d13244f0e.tar.gz |
COMPMID-1351: Valgrind: CannyEdge out of bound access in reference / trace_edge function
Change-Id: I8bb9beabf86d84576335b8b8c064045c7573b342
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/137987
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'tests/validation/reference/CannyEdgeDetector.cpp')
-rw-r--r-- | tests/validation/reference/CannyEdgeDetector.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/validation/reference/CannyEdgeDetector.cpp b/tests/validation/reference/CannyEdgeDetector.cpp index 6fe4544cf6..f1ad98cb3b 100644 --- a/tests/validation/reference/CannyEdgeDetector.cpp +++ b/tests/validation/reference/CannyEdgeDetector.cpp @@ -50,7 +50,7 @@ const auto MARK_MAYBE = 127u; const auto MARK_EDGE = 255u; template <typename T> -void trace_edge(SimpleTensor<T> &dst) +void trace_edge(SimpleTensor<T> &dst, const ValidRegion &valid_region) { std::stack<Coordinates> pixels_stack; for(auto i = 0; i < dst.num_elements(); ++i) @@ -83,12 +83,15 @@ void trace_edge(SimpleTensor<T> &dst) // Mark MAYBE neighbours as edges since they are next to an EDGE std::for_each(neighbours.begin(), neighbours.end(), [&](Coordinates & coord) { - const size_t pixel_index = coord2index(dst.shape(), coord); - const T pixel = dst[pixel_index]; - if(pixel == MARK_MAYBE) + if(is_in_valid_region(valid_region, coord)) { - dst[pixel_index] = MARK_EDGE; - pixels_stack.push(coord); + const size_t pixel_index = coord2index(dst.shape(), coord); + const T pixel = dst[pixel_index]; + if(pixel == MARK_MAYBE) + { + dst[pixel_index] = MARK_EDGE; + pixels_stack.push(coord); + } } }); } @@ -221,7 +224,7 @@ SimpleTensor<T> canny_edge_detector_impl(const SimpleTensor<T> &src, int32_t upp } // Final edge tracing - trace_edge<T>(dst); + trace_edge<T>(dst, valid_region); return dst; } } // namespace |