From 4c7931869490c3c662b1e548c4c22bd9ee7b52fb Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sat, 19 Mar 2022 06:52:47 +0000 Subject: [PATCH] dnn: fix index access --- modules/dnn/src/dnn.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index cbebad7e7c..b4fa8933c3 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -2759,8 +2759,12 @@ struct Net::Impl : public detail::NetImplBase it->second.out.empty()) { getLayerShapesRecursively(layerId, inOutShapes); + it = inOutShapes.find(layerId); + CV_Assert(it != inOutShapes.end()); } - const MatShape& shape = inOutShapes[layerId].out[inputLayerIds[i].oid]; + const int out_port = inputLayerIds[i].oid; + CV_CheckLT(out_port, (int)it->second.out.size(), ""); + const MatShape& shape = it->second.out[out_port]; layerShapes.in.push_back(shape); } }