mirror of
https://github.com/opencv/opencv.git
synced 2025-07-30 17:37:05 +08:00
Merge pull request #27353 from MRo47:fix/segfault-on-forward#27352
Fix #27352: Add checks before getting latest pin in Net::Impl::getLatestLayerPin() #27353 ### Pull Request Readiness Checklist Fixes #27352 See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
023d14ecc4
commit
374ad41420
@ -1027,6 +1027,8 @@ void Net::Impl::forward(OutputArrayOfArrays outputBlobs,
|
||||
const std::vector<String>& 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<LayerPin> pins;
|
||||
@ -1056,6 +1058,8 @@ void Net::Impl::forward(std::vector<std::vector<Mat>>& outputBlobs,
|
||||
const std::vector<String>& 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<LayerPin> pins;
|
||||
@ -1316,6 +1320,9 @@ void Net::Impl::updateLayersShapes()
|
||||
|
||||
LayerPin Net::Impl::getLatestLayerPin(const std::vector<LayerPin>& 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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user