prevent segfault on load fail

This commit is contained in:
Concedo
2026-09-13 22:01:18 +08:00
parent bcc718d836
commit 49b9132287
4 changed files with 19 additions and 4 deletions
+5
View File
@@ -322,6 +322,11 @@ std::string gguf_get_model_arch(const std::string & gguf_filename)
ggufparams.ctx = NULL;
auto ctx = gguf_init_from_file(fname.c_str(), ggufparams);
if (ctx == nullptr)
{
fprintf(stderr, "%s: error: failed to read GGUF file '%s'\n", __func__, fname.c_str());
return FileFormat::BADFORMAT;
}
auto keyidx = gguf_find_key(ctx, "general.architecture");
std::string modelarch = "";