]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
completion : Fix segfault on model load failure (#21049)
authormtmcp <redacted>
Fri, 27 Mar 2026 08:01:13 +0000 (05:01 -0300)
committerGitHub <redacted>
Fri, 27 Mar 2026 08:01:13 +0000 (10:01 +0200)
tools/completion/completion.cpp

index 58d598fcc07801684c3eb37b3a8dedfa70a193fc..a24482956e7b7e9117be2a0db64567e67297e900 100644 (file)
@@ -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);