mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +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() {
|
void* Buffer::raw_ptr() {
|
||||||
|
if (!ptr_) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return static_cast<MTL::Buffer*>(ptr_)->contents();
|
return static_cast<MTL::Buffer*>(ptr_)->contents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ Allocator& allocator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* Buffer::raw_ptr() {
|
void* Buffer::raw_ptr() {
|
||||||
|
if (!ptr_) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return static_cast<size_t*>(ptr_) + 1;
|
return static_cast<size_t*>(ptr_) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user