mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 06:41:31 +11:00
Merge pull request #536 from tomaka/fix-using-freed-memory
Fix calling XFree before reading from memory
This commit is contained in:
commit
0e3ce75969
|
@ -340,13 +340,14 @@ fn create_context(glx: &ffi::glx::Glx, extra_functions: &ffi::glx_extra::Glx, ex
|
||||||
unsafe fn enumerate_configs(glx: &ffi::glx::Glx, xlib: &ffi::Xlib, display: *mut ffi::Display)
|
unsafe fn enumerate_configs(glx: &ffi::glx::Glx, xlib: &ffi::Xlib, display: *mut ffi::Display)
|
||||||
-> Result<Vec<(ffi::glx::types::GLXFBConfig, PixelFormat)>, CreationError>
|
-> Result<Vec<(ffi::glx::types::GLXFBConfig, PixelFormat)>, CreationError>
|
||||||
{
|
{
|
||||||
let configs = {
|
let configs: Vec<ffi::glx::types::GLXFBConfig> = {
|
||||||
let mut num_configs = 0;
|
let mut num_configs = 0;
|
||||||
let vals = glx.GetFBConfigs(display as *mut _, 0, &mut num_configs); // TODO: screen number
|
let vals = glx.GetFBConfigs(display as *mut _, 0, &mut num_configs); // TODO: screen number
|
||||||
assert!(!vals.is_null());
|
assert!(!vals.is_null());
|
||||||
let configs = slice::from_raw_parts(vals, num_configs as usize);
|
let configs = slice::from_raw_parts(vals, num_configs as usize);
|
||||||
|
let ret = configs.to_vec();
|
||||||
(xlib.XFree)(vals as *mut _);
|
(xlib.XFree)(vals as *mut _);
|
||||||
configs.to_vec()
|
ret
|
||||||
};
|
};
|
||||||
|
|
||||||
let get_attrib = |attrib: libc::c_int, fb_config: ffi::glx::types::GLXFBConfig| -> i32 {
|
let get_attrib = |attrib: libc::c_int, fb_config: ffi::glx::types::GLXFBConfig| -> i32 {
|
||||||
|
|
Loading…
Reference in a new issue