mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-18 01:50:16 +08:00
Guard nullptr dereference (#1972)
* guard nullptr dereference * comment
This commit is contained in:
@@ -20,6 +20,9 @@ Allocator& allocator() {
|
||||
}
|
||||
|
||||
void* Buffer::raw_ptr() {
|
||||
if (!ptr_) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<MTL::Buffer*>(ptr_)->contents();
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,9 @@ Allocator& allocator() {
|
||||
}
|
||||
|
||||
void* Buffer::raw_ptr() {
|
||||
if (!ptr_) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<size_t*>(ptr_) + 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user