Skip to content

Commit 32e4f86

Browse files
committed
fix: prevent crash in case of a memory allocation error
...and ensure a graceful exit
1 parent a397e03 commit 32e4f86

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/model.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,12 @@ bool ModelLoader::load_tensors(on_new_tensor_cb_t on_new_tensor_cb, int n_thread
995995
continue;
996996
}
997997

998+
if (dst_tensor->data == nullptr) {
999+
LOG_ERROR("memory allocation failed '%s'", tensor_storage.name.c_str());
1000+
failed = true;
1001+
break;
1002+
}
1003+
9981004
// skip mmapped tensors
9991005
if (dst_tensor->buffer != nullptr && dst_tensor->buffer == fdata.mmbuffer.get()) {
10001006
continue;

0 commit comments

Comments
 (0)