]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
gguf : fix comparison (ggml/715)
authorGeorgi Gerganov <redacted>
Mon, 29 Jan 2024 19:08:18 +0000 (21:08 +0200)
committerGeorgi Gerganov <redacted>
Tue, 30 Jan 2024 19:27:59 +0000 (21:27 +0200)
ggml-ci

ggml.c

diff --git a/ggml.c b/ggml.c
index 954041e2a08cca4abb6e21e38af4be22499dca05..e6dce1c457a6a2374ef8c511a7efb507d145f62b 100644 (file)
--- a/ggml.c
+++ b/ggml.c
@@ -19421,7 +19421,7 @@ struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_p
                             case GGUF_TYPE_BOOL:
                                 {
                                     // prevent from integer overflow in the malloc below
-                                    if (kv->value.arr.n < SIZE_MAX/gguf_type_size(kv->value.arr.type)) {
+                                    if (kv->value.arr.n >= SIZE_MAX/gguf_type_size(kv->value.arr.type)) {
                                         fprintf(stderr, "%s: array size is too large (%" PRIu64 ")\n", __func__, kv->value.arr.n);
                                         fclose(file);
                                         gguf_free(ctx);
@@ -19435,7 +19435,7 @@ struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_p
                             case GGUF_TYPE_STRING:
                                 {
                                     // prevent from integer overflow in the malloc below
-                                    if (kv->value.arr.n < SIZE_MAX/sizeof(struct gguf_str)) {
+                                    if (kv->value.arr.n >= SIZE_MAX/sizeof(struct gguf_str)) {
                                         fprintf(stderr, "%s: array size is too large (%" PRIu64 ")\n", __func__, kv->value.arr.n);
                                         fclose(file);
                                         gguf_free(ctx);