Skip to content

Commit ebdc18e

Browse files
authored
Remove trivial and unnecessary UB
I don't understand why it was written this way. [glGenTextures](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGenTextures.xhtml) is passed a mutable pointer which is set as an out parameter, but the existing code was transmuting a shared reference to the buffer to a mutable pointer, which is undefined behavior. The fix is trivial: just make the buffer mutable and pass a mutable reference instead.
1 parent 4634642 commit ebdc18e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/texture/any.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ pub fn new_texture<'a, F: ?Sized, P>(facade: &F, format: TextureFormatRequest,
213213

214214
BufferAny::unbind_pixel_unpack(&mut ctxt);
215215

216-
let id: gl::types::GLuint = 0;
217-
ctxt.gl.GenTextures(1, mem::transmute(&id));
216+
let mut id: gl::types::GLuint = 0;
217+
ctxt.gl.GenTextures(1, &mut id);
218218

219219
{
220220
ctxt.gl.BindTexture(bind_point, id);

0 commit comments

Comments
 (0)