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(); crate::env_logger::init();
let args = unsafe { CStr::from_ptr(opts.args) }; let args = if !opts.args.is_null() {
let args = args let args = unsafe { CStr::from_ptr(opts.args) };
.to_str() args.to_str()
.unwrap_or("") .unwrap_or("")
.split(' ') .split(' ')
.map(|s| s.to_owned()) .map(|s| s.to_owned())
.collect(); .collect()
} else {
vec![]
};
let url = unsafe { CStr::from_ptr(opts.url) }; let url = unsafe { CStr::from_ptr(opts.url) };
let url = url.to_str().map(|s| s.to_string()).ok(); let url = url.to_str().map(|s| s.to_string()).ok();