Skip to content

Commit

Permalink
handle null args
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrouget committed Jun 6, 2019
1 parent 7a5ce04 commit 2fb6cc6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ports/libsimpleservo/capi/src/lib.rs
Expand Up @@ -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();
Expand Down

0 comments on commit 2fb6cc6

Please sign in to comment.