diff --git a/ports/libsimpleservo/capi/src/lib.rs b/ports/libsimpleservo/capi/src/lib.rs index 50af7a4d284..b080218492d 100644 --- a/ports/libsimpleservo/capi/src/lib.rs +++ b/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();