]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
gguf : handle null name during init (#8587)
authorGeorgi Gerganov <redacted>
Sat, 20 Jul 2024 14:15:42 +0000 (17:15 +0300)
committerGitHub <redacted>
Sat, 20 Jul 2024 14:15:42 +0000 (17:15 +0300)
examples/gguf/gguf.cpp
ggml/src/ggml.c

index 57514377107d7cd4beef073a33e798850b6816db..7498f85efc4f90cc3bc819659ee555a81af117e3 100644 (file)
@@ -92,6 +92,11 @@ static bool gguf_ex_read_0(const std::string & fname) {
 
     struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params);
 
+    if (!ctx) {
+        fprintf(stderr, "%s: failed to load '%s'\n", __func__, fname.c_str());
+        return false;
+    }
+
     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));
index 7a39c685b6f989946e8281dec6ba01a1d04ff822..dbb3a3ebe1cca45465fcbd63a9d78402c4b5d71c 100644 (file)
@@ -21015,7 +21015,7 @@ struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_p
             gguf_tensor_info_sanitize(info);
 
             // make sure there is no duplicated tensor names
-            for (uint64_t j = 0; j < i; ++j) {
+            for (uint64_t j = 0; j < i && ok; ++j) {
                 if (strcmp(info->name.data, ctx->infos[j].name.data) == 0) {
                     fprintf(stderr, "%s: duplicated tensor name %s\n", __func__, info->name.data);
                     ok = false;