Skip to content

Commit

Permalink
Fix heap buffer overflow due to operator precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin authored and sdroege committed Jun 6, 2023
1 parent f54c9b2 commit 01a5517
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion glib/src/collections/strv.rs
Expand Up @@ -446,8 +446,10 @@ impl StrV {
if len == 0 {
StrV::default()
} else {
// Allocate space for len + 1 pointers, one pointer for each string and a trailing
// null pointer.
let new_ptr =
ffi::g_malloc(mem::size_of::<*mut c_char>() * len + 1) as *mut *mut c_char;
ffi::g_malloc(mem::size_of::<*mut c_char>() * (len + 1)) as *mut *mut c_char;

// Need to clone every item because we don't own it here
for i in 0..len {
Expand Down

0 comments on commit 01a5517

Please sign in to comment.