Skip to content

Commit 071ee66

Browse files
committed
rs: zero initialize cs_insn to make valgrind happy
1 parent 36a2b30 commit 071ee66

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

capstone-rs/src/capstone.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,22 @@ impl Capstone {
231231
if insn.is_null() {
232232
return Err(Error::OutOfMemory);
233233
}
234+
// zero initialize cs_insn
235+
unsafe {
236+
*insn = cs_insn {
237+
id: 0,
238+
alias_id: 0,
239+
address: 0,
240+
size: 0,
241+
bytes: [0; 24],
242+
mnemonic: [0; 32],
243+
op_str: [0; 160],
244+
is_alias: false,
245+
usesAliasDetails: false,
246+
illegal: false,
247+
detail: (*insn).detail,
248+
};
249+
}
234250
Ok(DisasmIter {
235251
insn,
236252
csh: self.csh,

0 commit comments

Comments
 (0)