From 32e4f861d6c79912fc068b5ef02ced25722cacf7 Mon Sep 17 00:00:00 2001 From: akleine Date: Tue, 26 May 2026 16:05:35 +0200 Subject: [PATCH] fix: prevent crash in case of a memory allocation error ...and ensure a graceful exit --- src/model.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/model.cpp b/src/model.cpp index 8351a2be6..f7fb7fa22 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -995,6 +995,12 @@ bool ModelLoader::load_tensors(on_new_tensor_cb_t on_new_tensor_cb, int n_thread continue; } + if (dst_tensor->data == nullptr) { + LOG_ERROR("memory allocation failed '%s'", tensor_storage.name.c_str()); + failed = true; + break; + } + // skip mmapped tensors if (dst_tensor->buffer != nullptr && dst_tensor->buffer == fdata.mmbuffer.get()) { continue;