Skip to content

Commit 844cd7a

Browse files
committed
Fix use-after-free in Graph::to_function
1 parent 0a35866 commit 844cd7a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/graph.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,9 @@ impl Graph {
669669
None => None,
670670
Some(r) => Some(r?),
671671
};
672-
// Don't use Option::map because the CStrings need to outlive the
673-
// pointers and Option::map consumes the Option.
674-
let output_names_ptrs: Option<Vec<*const c_char>> =
675-
output_names_cstrs.map(|slice| slice.iter().map(|s| s.as_ptr()).collect());
672+
let output_names_ptrs: Option<Vec<*const c_char>> = output_names_cstrs
673+
.as_ref()
674+
.map(|slice| slice.iter().map(|s| s.as_ptr()).collect());
676675
let output_names_ptrs_ptr = match &output_names_ptrs {
677676
None => ptr::null(),
678677
Some(ref v) => v.as_ptr(),

0 commit comments

Comments
 (0)