From: mtmcp Date: Fri, 27 Mar 2026 08:01:13 +0000 (-0300) Subject: completion : Fix segfault on model load failure (#21049) X-Git-Tag: upstream/0.0.8611~61 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=a308e584cae3fa8cee1d739a858a2d780f1de009;p=pkg%2Fggml%2Fsources%2Fllama.cpp completion : Fix segfault on model load failure (#21049) --- diff --git a/tools/completion/completion.cpp b/tools/completion/completion.cpp index 58d598fcc..a24482956 100644 --- a/tools/completion/completion.cpp +++ b/tools/completion/completion.cpp @@ -146,13 +146,19 @@ int main(int argc, char ** argv) { ctx = llama_init->context(); model = llama_init->model(); - smpl = llama_init->sampler(0); if (ctx == NULL) { LOG_ERR("%s: error: unable to create context\n", __func__); return 1; } + if (model == NULL) { + LOG_ERR("%s: error: unable to load model\n", __func__); + return 1; + } + + smpl = llama_init->sampler(0); + llama_memory_t mem = llama_get_memory(ctx); const llama_vocab * vocab = llama_model_get_vocab(model);