bound dilate and erode width to avoid mask-size overflow - #4548
Merged
Conversation
Owner
|
Thanks for the PR to fix this. Is there a reason for the 1000 limit? I think it might need to be a bit higher than this, perhaps 65536 (1 << 16)? |
Contributor
Author
|
No strong reason for 1000, I just matched the bound |
Owner
|
Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unbounded dilate/erode width overflows the mask size
dilate()anderode()accept any positive integer, unlike the siblingmedian()which bounds its window to 1 to 1000, so an oversized width reaches the nativeDilate/Erodewhere the structuring element is sized as2 * width + 1and passed tonew_matrix; read throughAttrAsUint32into anint, a width of2^30wraps that signed size negative and2^32narrows it to zero, silently dropping the operation. Bounded the width to matchmedianso the value can no longer reach that calculation.