]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
fix: check model pointer validity before use (#13631)
authorNick <redacted>
Mon, 19 May 2025 10:25:41 +0000 (18:25 +0800)
committerGitHub <redacted>
Mon, 19 May 2025 10:25:41 +0000 (13:25 +0300)
examples/simple/simple.cpp

index 10e79a0a69eebe48c5788b923b94ab82fb813dc2..633b87e58406e3789d367139b535469c8c16a9c0 100644 (file)
@@ -84,13 +84,13 @@ int main(int argc, char ** argv) {
     model_params.n_gpu_layers = ngl;
 
     llama_model * model = llama_model_load_from_file(model_path.c_str(), model_params);
-    const llama_vocab * vocab = llama_model_get_vocab(model);
 
     if (model == NULL) {
         fprintf(stderr , "%s: error: unable to load model\n" , __func__);
         return 1;
     }
 
+    const llama_vocab * vocab = llama_model_get_vocab(model);
     // tokenize the prompt
 
     // find the number of tokens in the prompt