Auto merge of #23501 - paulrouget:nullcheck, r=jdm

handle null args pointer

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23501)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-06-06 03:14:11 -04:00 committed by GitHub
commit 347d8bdf72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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();