Skip to content

Commit 33e65d0

Browse files
committed
Fix to deal with erroneous case of cstring cast
1 parent 523ec5b commit 33e65d0

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

rclrs/src/node/builder.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,23 +282,15 @@ impl NodeBuilder {
282282
// SAFETY: No preconditions for this function.
283283
let mut node_options = unsafe { rcl_node_get_default_options() };
284284

285-
let (cstring_args_results, mut parse_err_results): (Vec<_>, Vec<_>) = self
285+
let cstring_args = self
286286
.arguments
287287
.iter()
288288
.map(|s| match CString::new(s.as_str()) {
289289
Ok(cstr) => Ok(cstr),
290290
Err(err) => Err(RclrsError::StringContainsNul { s: s.clone(), err }),
291291
})
292-
.partition(Result::is_ok);
292+
.collect::<Result<Vec<_>, _>>()?;
293293

294-
if let Some(err) = parse_err_results.pop() {
295-
return Err(err.unwrap_err());
296-
}
297-
298-
let cstring_args = cstring_args_results
299-
.into_iter()
300-
.map(|r| r.unwrap())
301-
.collect::<Vec<_>>();
302294
let cstring_arg_ptrs = cstring_args.iter().map(|s| s.as_ptr()).collect::<Vec<_>>();
303295
// SAFETY: Getting a zero-initialized value is always safe.
304296
unsafe {

0 commit comments

Comments
 (0)