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
A new MTLTexture instance if the method completed successfully; otherwise nil.
The metal::Texture type wraps a NonNull<_> value (from cargo expand texture):
/// See <https://developer.apple.com/documentation/metal/mtltexture>pubenumMTLTexture{}#[repr(transparent)]pubstructTexture(::foreign_types::export::NonNull<MTLTexture>);
So when that call fails new_texture will put a null ptr in a NonNullwhich is UB:
I was taking a look at the method and noticed it doesn't check what the
newTextureWithDescriptor
msg_send!
returns.According to the docs that call can return:
The
metal::Texture
type wraps aNonNull<_>
value (fromcargo expand texture
):So when that call fails
new_texture
will put a null ptr in aNonNull
which is UB:Seems like there's people already hitting those cases and
wgpu
now checks if the wrapped ptr is null, but that doesn't deal with the UB.Let me know if I'm missing something, otherwise I can create a PR to perform the check and make
create_texture
return anOption<Texture>
The text was updated successfully, but these errors were encountered: