Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

r2d3
Copy link
Contributor

@r2d3 r2d3 commented Jul 15, 2022

Python binding is passing NULL as (int*)value.
sliderChanged crash when trying to dereference value

A user reported this issue to me on IRC and opened an issue in opencv-python
opencv/opencv-python#691

I have a solution for the issue but I do not know which OpenCV branch I should target

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

if (value)
text = [NSString stringWithFormat:@"%@ %d", temp, *value];
else
text = [NSString stringWithFormat:@"%@ %d", temp, pos];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could use only this case ?
Is there use case where the user fill *value with the value he wants to be displayed ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets just replace *value -> pos unconditionally.

-NSString *text = [NSString stringWithFormat:@"%@ %d", temp, *value];
+NSString *text = [NSString stringWithFormat:@"%@ %d", temp, pos];

relates #22047

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix!

4.x branch is fine for this patch.

if (value)
text = [NSString stringWithFormat:@"%@ %d", temp, *value];
else
text = [NSString stringWithFormat:@"%@ %d", temp, pos];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets just replace *value -> pos unconditionally.

-NSString *text = [NSString stringWithFormat:@"%@ %d", temp, *value];
+NSString *text = [NSString stringWithFormat:@"%@ %d", temp, pos];

relates #22047

Python binding is passing NULL as (int*)value.
sliderChanged crash when trying to dereference value
@r2d3 r2d3 force-pushed the python_trackbar_macos branch from 74b9467 to 60846b2 Compare July 15, 2022 20:02
@opencv-pushbot opencv-pushbot merged commit 96a9cfa into opencv:4.x Jul 16, 2022
@alalek alalek mentioned this pull request Aug 21, 2022
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