mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Unconditionally create SuperScale in BarcodeDetector to avoid null deref
This pointer is called unconditionally in BarcodeImpl::initDecode assuming the size of the image is outside the specified bounds. This seems to not cause problems on optimized builds, I assume because the optimizer sees through the processImageScale call to see that it can be reduced to a resize call. Leaving it as is relies on undefined behavior. This was the least invasive change I could make, however, it might be worthwhile to pull up the logic for a resize so that a SuperScale does not need to be allocated, which seems to be the most common case.
This commit is contained in:
parent
c96f48e7c9
commit
fcdaaabf7c
@ -343,11 +343,11 @@ BarcodeDetector::BarcodeDetector(const string &prototxt_path, const string &mode
|
||||
{
|
||||
Ptr<BarcodeImpl> p_ = new BarcodeImpl();
|
||||
p = p_;
|
||||
p_->sr = make_shared<SuperScale>();
|
||||
if (!prototxt_path.empty() && !model_path.empty())
|
||||
{
|
||||
CV_Assert(utils::fs::exists(prototxt_path));
|
||||
CV_Assert(utils::fs::exists(model_path));
|
||||
p_->sr = make_shared<SuperScale>();
|
||||
int res = p_->sr->init(prototxt_path, model_path);
|
||||
CV_Assert(res == 0);
|
||||
p_->use_nn_sr = true;
|
||||
|
Loading…
Reference in New Issue
Block a user