You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Considering that pub mod d3d12, and from_winapi_d3d12_resource_desc is also a pub function. I assume that users can directly call this function. This potential situation could result in device.GetResourceAllocationInfo(0, std::slice::from_ref(desc)) operating on a null pointer, I am not sure what will null_pointer.GetResourceAllocationInfo do but I guess it might trigger undefined behavior (UB). For safety reasons, I felt it necessary to report this issue. If you have performed checks elsewhere that ensure this is safe, please don’t take offense at my raising this issue.
I suggest Several possible fixes:
If there is no external usage for from_winapi_d3d12_resource_desc it should not marked as pub.
from_winapi_d3d12_resource_desc method should add additional check for null pointer.
mark from_winapi_d3d12_resource_desc method as unsafe and proper doc to let users know that they should provide valid Pointers.
The text was updated successfully, but these errors were encountered:
Thanks for pointing that out - yeah I think this function is simply lacking unsafe. A null check won't cut it since the pointer is dereferenced: any invaliddevice pointer will also trigger UB.
I've been meaning to remove the winapi compatibility layer. It's messy, ugly, and UB as you've shown, and serves no purpose given that windows is superior and more complete in every aspect.
Hello, thank you for your contribution in this project, I am scanning the unsoundness problem in rust project.
I notice the following code:
Considering that
pub mod d3d12
, andfrom_winapi_d3d12_resource_desc
is also a pub function. I assume that users can directly call this function. This potential situation could result indevice.GetResourceAllocationInfo(0, std::slice::from_ref(desc))
operating on a null pointer, I am not sure what willnull_pointer.GetResourceAllocationInfo
do but I guess it might trigger undefined behavior (UB). For safety reasons, I felt it necessary to report this issue. If you have performed checks elsewhere that ensure this is safe, please don’t take offense at my raising this issue.I suggest Several possible fixes:
from_winapi_d3d12_resource_desc
it should not marked aspub
.from_winapi_d3d12_resource_desc
method should add additional check for null pointer.from_winapi_d3d12_resource_desc
method as unsafe and proper doc to let users know that they should provide valid Pointers.The text was updated successfully, but these errors were encountered: