Skip to content

Commit

Permalink
config: fix dangling pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
panekj authored and poljar committed Nov 11, 2024
1 parent be0adeb commit 5b4eb1c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions crates/weechat/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,7 @@ impl Conf {

let option_name = LossyCString::new(key);

let c_value = match value {
Some(v) => LossyCString::new(v).as_ptr(),
None => ptr::null(),
};
let c_value = value.map(LossyCString::new).map(|v| v.as_ptr()).unwrap_or(ptr::null());

unsafe {
write_line(self.ptr, option_name.as_ptr(), c_value);
Expand Down

0 comments on commit 5b4eb1c

Please sign in to comment.