Fix find_context

This commit is contained in:
SoniEx2 2018-03-31 15:12:56 -03:00
parent 6d5d3e7297
commit 6dd8cc2dc4
1 changed files with 5 additions and 3 deletions

View File

@ -635,10 +635,12 @@ impl<'a> EnsureValidContext<'a> {
pub fn find_context(&mut self, servname: Option<&str>, channel: Option<&str>) -> Option<Context> {
// this was a mistake but oh well
let ph = self.ph.ph;
let servname = CString::new(servname).unwrap();
let channel = CString::new(channel).unwrap();
let servname = servname.map(|x| CString::new(x).unwrap());
let channel = channel.map(|x| CString::new(x).unwrap());
let ctx = unsafe {
((*ph).hexchat_find_context)(ph, servname.as_ptr(), channel.as_ptr())
let sptr = servname.map(|x| x.as_ptr()).unwrap_or(ptr::null());
let cptr = channel.map(|x| x.as_ptr()).unwrap_or(ptr::null());
((*ph).hexchat_find_context)(ph, sptr, cptr)
};
if ctx.is_null() {
None