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
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.
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.
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
The text was updated successfully, but these errors were encountered: