From 39850773314a491db211c73bb547a1ac1b0e6711 Mon Sep 17 00:00:00 2001 From: Cebtenzzre Date: Wed, 30 Aug 2023 14:40:08 -0400 Subject: [PATCH] llama2c : fix segfault if vocab is not found --- examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp b/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp index e9e070b1f..3cbd631cc 100644 --- a/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp +++ b/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp @@ -596,6 +596,10 @@ void load_vocab(const char *filename, Config *config, struct llama_vocab *vocab) // assume llama2.c vocabulary printf("Assuming llama2.c vocabulary since %s is not a gguf file\n", filename); llama_file file(filename, "rb"); + if (!file.fp) { + fprintf(stderr, "error: %s: %s\n", strerror(errno), filename); + exit(1); + } const int n_vocab = config->vocab_size; /* uint32_t max_token_length = */ file.read_u32(); // unused vocab->id_to_token.resize(n_vocab);