From c1e6bcb3e448962b5f4cf4453e629eae1a82b943 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sun, 8 Jul 2018 00:37:20 +0200 Subject: Always free string pointers returned by libnitrokey Old libnitrokey versions could return pointers to both statically and dynamically allocated strings for functions that return strings. This has been fixed in libnitrokey commit 7a8550d (included in v3.4). This patch removes the old workaround and always frees the return value of functions returning a string pointer. --- src/util.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/util.rs b/src/util.rs index d764baa..6f4fbb0 100644 --- a/src/util.rs +++ b/src/util.rs @@ -73,11 +73,10 @@ pub fn result_from_string(ptr: *const c_char) -> Result { } unsafe { let s = owned_str_from_ptr(ptr); + free(ptr as *mut c_void); if s.is_empty() { return Err(get_last_error()); } - // TODO: move up for newer libnitrokey versions - free(ptr as *mut c_void); return Ok(s); } } -- cgit v1.2.3