From 7e14b4bba1766641975c88ca8a0bbf51511461f4 Mon Sep 17 00:00:00 2001 From: leatherwang Date: Tue, 4 Jan 2022 11:36:48 +0800 Subject: [PATCH] Fix array out of range when too many line segments extracted --- modules/line_descriptor/src/binary_descriptor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/line_descriptor/src/binary_descriptor.cpp b/modules/line_descriptor/src/binary_descriptor.cpp index c9620c38f..6e5b1577d 100644 --- a/modules/line_descriptor/src/binary_descriptor.cpp +++ b/modules/line_descriptor/src/binary_descriptor.cpp @@ -2467,6 +2467,11 @@ int BinaryDescriptor::EDLineDetector::EDline( cv::Mat &image, LineChains &lines offsetInLineArray = pLineSID[numOfLines]; // line was not accepted, the offset is set back } } + // Avoid array out of range + if(numOfLines >= lines.sId.size()) { + lines.sId.push_back(offsetInLineArray); + pLineSID = &lines.sId.front(); + } //Extract line segments from the remaining pixel; Current chain has been shortened already. } } //end for(unsigned int edgeID=0; edgeID