handle null args

This commit is contained in:
Paul Rouget 2019-06-06 08:16:26 +02:00
parent 7a5ce048d2
commit 2fb6cc6f4d

View file

@ -75,13 +75,16 @@ fn init(
) {
crate::env_logger::init();
let args = unsafe { CStr::from_ptr(opts.args) };
let args = args
.to_str()
.unwrap_or("")
.split(' ')
.map(|s| s.to_owned())
.collect();
let args = if !opts.args.is_null() {
let args = unsafe { CStr::from_ptr(opts.args) };
args.to_str()
.unwrap_or("")
.split(' ')
.map(|s| s.to_owned())
.collect()
} else {
vec![]
};
let url = unsafe { CStr::from_ptr(opts.url) };
let url = url.to_str().map(|s| s.to_string()).ok();