diff --git a/modules/dnn/src/net_impl.cpp b/modules/dnn/src/net_impl.cpp index 28db8c0566..6684a4f7b0 100644 --- a/modules/dnn/src/net_impl.cpp +++ b/modules/dnn/src/net_impl.cpp @@ -1027,6 +1027,8 @@ void Net::Impl::forward(OutputArrayOfArrays outputBlobs, const std::vector& outBlobNames) { CV_Assert(!empty()); + if (outBlobNames.empty()) + CV_Error(Error::StsBadArg, "in Net::forward(), outBlobNames cannot be empty"); FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; std::vector pins; @@ -1056,6 +1058,8 @@ void Net::Impl::forward(std::vector>& outputBlobs, const std::vector& outBlobNames) { CV_Assert(!empty()); + if (outBlobNames.empty()) + CV_Error(Error::StsBadArg, "in Net::forward(), outBlobNames cannot be empty"); FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; std::vector pins; @@ -1316,6 +1320,9 @@ void Net::Impl::updateLayersShapes() LayerPin Net::Impl::getLatestLayerPin(const std::vector& pins) const { + if (pins.empty()) + CV_Error(Error::StsBadArg, + "Cannot Net::Impl::getLatestLayerPin() from empty vector of pins"); return *std::max_element(pins.begin(), pins.end()); }