mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-25 01:41:17 +08:00
Guard nullptr dereference (#1972)
* guard nullptr dereference * comment
This commit is contained in:
parent
3779150750
commit
f90206ad74
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user