From: Georgi Gerganov Date: Mon, 29 Jan 2024 19:08:18 +0000 (+0200) Subject: gguf : fix comparison (ggml/715) X-Git-Tag: upstream/0.0.4488~2466 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=6fb50ebbf036ac57a20fe8d8da31731a543582d5;p=pkg%2Fggml%2Fsources%2Fllama.cpp gguf : fix comparison (ggml/715) ggml-ci --- diff --git a/ggml.c b/ggml.c index 12e2173e..a7a9ea31 100644 --- a/ggml.c +++ b/ggml.c @@ -19451,7 +19451,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); @@ -19465,7 +19465,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);