From e9d2e4691c58a8ec4dea33d12fc821f5f6d883c1 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 28 Jun 2020 17:09:45 -0700 Subject: [PATCH] Fix temporary_cstring_as_ptr lint, using freed memory --- azure-pipelines.yml | 2 +- src/gl/mod.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 73e954d..1889625 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -6,7 +6,7 @@ jobs: displayName: "Install build dependencies" condition: eq(variables['Agent.OS'], 'Linux') minrust: 1.44.1 - clippy: -A clippy::temporary_cstring_as_ptr -A clippy::not_unsafe_ptr_arg_deref -A clippy::float_cmp + clippy: -A clippy::not_unsafe_ptr_arg_deref -A clippy::float_cmp resources: repositories: diff --git a/src/gl/mod.rs b/src/gl/mod.rs index 52e6b8a..21eec07 100644 --- a/src/gl/mod.rs +++ b/src/gl/mod.rs @@ -536,8 +536,9 @@ impl Program { } pub fn uniform_location(&self, name: &str) -> Option { + let c_name = ffi::CString::new(name).unwrap(); let u = - unsafe { gl::GetUniformLocation(self.0, ffi::CString::new(name).unwrap().as_ptr()) }; + unsafe { gl::GetUniformLocation(self.0, c_name.as_ptr()) }; if u != -1 { Some(Uniform(u)) } else {