Skip to content

Commit 0f4f7c6

Browse files
kawadakksdroege
authored andcommitted
glib: Ensure NULL terminator is present after creating allocation in StrV::reserve
1 parent 8335a24 commit 0f4f7c6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

glib/src/collections/strv.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,9 @@ impl StrV {
714714
.checked_mul(new_capacity)
715715
.unwrap(),
716716
) as *mut *mut c_char;
717+
if self.capacity == 0 {
718+
*new_ptr = ptr::null_mut();
719+
}
717720
self.ptr = ptr::NonNull::new_unchecked(new_ptr);
718721
self.capacity = new_capacity;
719722
}

0 commit comments

Comments
 (0)