diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp index 9ab63a293..2d14897ea 100644 --- a/examples/gguf/gguf.cpp +++ b/examples/gguf/gguf.cpp @@ -92,7 +92,10 @@ static bool gguf_ex_read_0(const std::string & fname) { }; struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params); - + if (NULL == ctx) { + fprintf(stderr, "could not retrieve GGUF data context from file.\n"); + exit(1); + } printf("%s: version: %d\n", __func__, gguf_get_version(ctx)); printf("%s: alignment: %zu\n", __func__, gguf_get_alignment(ctx)); printf("%s: data offset: %zu\n", __func__, gguf_get_data_offset(ctx)); @@ -152,7 +155,10 @@ static bool gguf_ex_read_1(const std::string & fname) { }; struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params); - + if (NULL == ctx) { + fprintf(stderr, "could not retrieve GGUF data context from file.\n"); + exit(1); + } printf("%s: version: %d\n", __func__, gguf_get_version(ctx)); printf("%s: alignment: %zu\n", __func__, gguf_get_alignment(ctx)); printf("%s: data offset: %zu\n", __func__, gguf_get_data_offset(ctx));