Throw an exception on a failed new in frida ASan, instead of just returning null (#512)
This commit is contained in:
parent
fb21c4ff82
commit
e41b76fe31
@ -54,7 +54,19 @@ impl AsanRuntime {
|
||||
#[allow(non_snake_case)]
|
||||
#[inline]
|
||||
pub fn hook__Znwm(&mut self, size: usize) -> *mut c_void {
|
||||
unsafe { self.allocator_mut().alloc(size, 8) }
|
||||
let result = unsafe { self.allocator_mut().alloc(size, 8) };
|
||||
if result.is_null() {
|
||||
extern "C" {
|
||||
fn _ZSt17__throw_bad_allocv();
|
||||
}
|
||||
|
||||
unsafe {
|
||||
_ZSt17__throw_bad_allocv();
|
||||
}
|
||||
0xabcdef as *mut c_void
|
||||
} else {
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
@ -70,7 +82,17 @@ impl AsanRuntime {
|
||||
#[allow(non_snake_case)]
|
||||
#[inline]
|
||||
pub fn hook__ZnwmSt11align_val_t(&mut self, size: usize, alignment: usize) -> *mut c_void {
|
||||
unsafe { self.allocator_mut().alloc(size, alignment) }
|
||||
let result = unsafe { self.allocator_mut().alloc(size, alignment) };
|
||||
if result.is_null() {
|
||||
extern "C" {
|
||||
fn _ZSt17__throw_bad_allocv();
|
||||
}
|
||||
|
||||
unsafe {
|
||||
_ZSt17__throw_bad_allocv();
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user