From 65d56e55216beed99f4bb81eddaffa8bafbdb33e Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 22 Jul 2015 08:39:31 +0200 Subject: Fix calling XFree before reading from memory --- src/api/glx/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/api/glx/mod.rs') diff --git a/src/api/glx/mod.rs b/src/api/glx/mod.rs index 65819f8..f640bee 100644 --- a/src/api/glx/mod.rs +++ b/src/api/glx/mod.rs @@ -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) -> Result, CreationError> { - let configs = { + let configs: Vec = { let mut num_configs = 0; let vals = glx.GetFBConfigs(display as *mut _, 0, &mut num_configs); // TODO: screen number assert!(!vals.is_null()); let configs = slice::from_raw_parts(vals, num_configs as usize); + let ret = configs.to_vec(); (xlib.XFree)(vals as *mut _); - configs.to_vec() + ret }; let get_attrib = |attrib: libc::c_int, fb_config: ffi::glx::types::GLXFBConfig| -> i32 { -- cgit v1.2.3