mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
handle null args
This commit is contained in:
parent
7a5ce048d2
commit
2fb6cc6f4d
1 changed files with 10 additions and 7 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue