audit use of to_cstring and fix ub

This commit is contained in:
dignifiedquire
2019-07-18 22:47:47 +02:00
committed by holger krekel
parent 618087e5a7
commit c68e7ae14e
26 changed files with 265 additions and 247 deletions

View File

@@ -71,7 +71,12 @@ impl Context {
Config::Selfavatar => {
let rel_path = self.sql.get_config(self, key);
rel_path.map(|p| {
let v = unsafe { dc_get_abs_path(self, to_cstring(p).as_ptr()) };
let v = unsafe {
let n = to_cstring(p);
let res = dc_get_abs_path(self, n);
free(n as *mut libc::c_void);
res
};
let r = to_string(v);
unsafe { free(v as *mut _) };
r