From f720261d46947ad5d6a80645964458dda7721793 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Mon, 26 Feb 2024 09:04:14 -0500 Subject: [PATCH] Fix another vulnerable spot for crashes. Signed-off-by: Adam Treat --- gpt4all-backend/llamamodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gpt4all-backend/llamamodel.cpp b/gpt4all-backend/llamamodel.cpp index e0389229..d2b25b8a 100644 --- a/gpt4all-backend/llamamodel.cpp +++ b/gpt4all-backend/llamamodel.cpp @@ -122,6 +122,8 @@ static gguf_context *load_gguf(const char *fname) { static int32_t get_arch_key_u32(std::string const &modelPath, std::string const &archKey) { auto * ctx = load_gguf(modelPath.c_str()); + if (!ctx) + return -1; auto arch = get_arch_name(ctx); int32_t value = -1;