-
Notifications
You must be signed in to change notification settings - Fork 640
Fix WarpPerspective::GetFillValue. #5575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add more error checks. Minor style fixes and improved structure packing. Signed-off-by: Michal Zientkiewicz <[email protected]>
std::vector<float> fill_value_arg_{0, 0, 0, 0}; | ||
float4 fill_value_{0, 0, 0, 0}; | ||
float4 fill_value_; | ||
bool inverse_map_ = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting small fields next to one another improves structure packing.
if (channels > 4) | ||
DALI_FAIL("Images with more than 4 channels are not supported."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use float4
for fill_value.
CI MESSAGE: [16804669]: BUILD STARTED |
@@ -108,16 +108,16 @@ class WarpPerspective : public nvcvop::NVCVSequenceOperator<StatelessOperator> { | |||
float4 GetFillValue(int channels) const { | |||
if (fill_value_arg_.size() > 1) { | |||
if (channels > 0) { | |||
if (channels == static_cast<int>(fill_value_arg_.size())) { | |||
float4 fill_value{0, 0, 0, 0}; | |||
memcpy(&fill_value, fill_value_arg_.data(), sizeof(decltype(fill_value))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug is in this line - fill_value_arg_ is constructed with exact length in line 95, overriding the default constructor from 233, which is never used. This leads to invalid read of size 16, which is up to 12 bytes beyond the vector end.
CI MESSAGE: [16804669]: BUILD PASSED |
Category:
Bug fix (non-breaking change which fixes an issue)
Refactoring (Redesign of existing code that doesn't affect functionality)
Description:
Fix copying FillValue - use actual number of elements in the vector.
Check that the number of channels doesn't exceed 4 (CV-CUDA limit).
Minor style fixes and improved structure packing.
Additional information:
Affected modules and functionalities:
Key points relevant for the review:
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: DALI-4041