Skip to content

Commit

Permalink
guard DisassemblyTextLine Drop against null ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
rbran committed Apr 11, 2024
1 parent 38c68b5 commit c54ccd2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rust/src/disassembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@ impl Default for DisassemblyTextLine {

impl Drop for DisassemblyTextLine {
fn drop(&mut self) {
let ptr = core::ptr::slice_from_raw_parts_mut(self.0.tokens, self.0.count);
let _ = unsafe { Box::from_raw(ptr) };
if !self.0.tokens.is_null() {
let ptr = core::ptr::slice_from_raw_parts_mut(self.0.tokens, self.0.count);
let _ = unsafe { Box::from_raw(ptr) };
}
}
}

Expand Down

0 comments on commit c54ccd2

Please sign in to comment.