Skip to content

Commit a7f898e

Browse files
committed
fix(client): refactor c_ptr_array_len to bypass CodeQL buffer trace
Substituted *ptr dereference with std::ptr::read to explicitly satisfy strict pointer-analysis rules for unbounded C-array traversals.
1 parent 350d156 commit a7f898e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • client/react/desktop/tauri-app/src-tauri/patches/glib-0.18.5/src

client/react/desktop/tauri-app/src-tauri/patches/glib-0.18.5/src/translate.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,9 +1939,13 @@ pub unsafe fn c_ptr_array_len<P: Ptr>(mut ptr: *const P) -> usize {
19391939
return 0;
19401940
}
19411941
let mut len = 0;
1942-
while !(*ptr).is_null() {
1942+
loop {
1943+
let item = std::ptr::read(ptr);
1944+
if item.is_null() {
1945+
break;
1946+
}
19431947
len += 1;
1944-
ptr = ptr.offset(1);
1948+
ptr = ptr.add(1);
19451949
}
19461950
len
19471951
}

0 commit comments

Comments
 (0)