summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2018-03-31 15:12:56 -0300
committerSoniEx2 <endermoneymod@gmail.com>2018-03-31 15:12:56 -0300
commit6dd8cc2dc4569766d573c21afa71632b7c8d0d96 (patch)
treed1be8e981b16a7214a19bc35eefd3439b942d9bd /src
parent6d5d3e72974dcd1e70c2e4e339530bee1263114a (diff)
Fix find_context
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 45b3c66..0bc0f6d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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