Skip to content
Permalink
Browse files

handle null args

  • Loading branch information...
paulrouget committed Jun 6, 2019
1 parent 7a5ce04 commit 2fb6cc6f4d2e6ea662c781b65bcafff3221461e1
Showing with 10 additions and 7 deletions.
  1. +10 −7 ports/libsimpleservo/capi/src/lib.rs
@@ -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();

0 comments on commit 2fb6cc6

Please sign in to comment.
You can’t perform that action at this time.