Skip to content

Unconditionally create SuperScale in BarcodeDetector to avoid null deref#24429

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
vrabaud:inter_area1
Oct 20, 2023
Merged

Unconditionally create SuperScale in BarcodeDetector to avoid null deref#24429
asmorkalov merged 1 commit intoopencv:4.xfrom
vrabaud:inter_area1

Conversation

@vrabaud
Copy link
Copy Markdown
Contributor

@vrabaud vrabaud commented Oct 19, 2023

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.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • 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 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.
@vrabaud vrabaud requested a review from asmorkalov October 19, 2023 20:44
@asmorkalov asmorkalov requested a review from mshabunin October 20, 2023 05:27
@vrabaud vrabaud removed the request for review from asmorkalov October 20, 2023 07:27
@asmorkalov asmorkalov added this to the 4.9.0 milestone Oct 20, 2023
@asmorkalov asmorkalov merged commit 1aa4621 into opencv:4.x Oct 20, 2023
@asmorkalov asmorkalov mentioned this pull request Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants