glutin
glutin copied to clipboard
[Bug] Getting opengl function address panics if the address contains a null terminator
Window.get_proc_address accepts a &str which gets then converted to a CString without checking for null bytes and just calling unwrap. Passing a &str with internal null bytes will crash the program. The conversion can also be expensive considering that most opengl loaders will use a CString/CStr directly. This means that in most cases the following conversion happens: CString => &str => CString.
it's probably a good idea for get_proc_address to ask directly for a &CStr and let the library user handle the conversion if necessary.
related #1314
That makes sense, could probably change that.
Upon further inspection it looks like some tools like the one used in the examples (gl_generator) use &str for loading, hence probably why that was used. Making a change like that probably also means changing the generator used. Phosporus seems to be the best alternative, it used by glow and transitively by bigger projects like wgpu and bevy.
Fixed in https://github.com/rust-windowing/glutin/pull/1435.