From: Nick Date: Mon, 19 May 2025 10:25:41 +0000 (+0800) Subject: fix: check model pointer validity before use (#13631) X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=9c55e5c5c24990dd17fd6c8f4f2159052d2b06f1;p=pkg%2Fggml%2Fsources%2Fllama.cpp fix: check model pointer validity before use (#13631) --- diff --git a/examples/simple/simple.cpp b/examples/simple/simple.cpp index 10e79a0a..633b87e5 100644 --- a/examples/simple/simple.cpp +++ b/examples/simple/simple.cpp @@ -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