]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
gguf : fix potential infinite for-loop (llama/4600)
authortexmex76 <redacted>
Sat, 13 Jan 2024 16:06:20 +0000 (17:06 +0100)
committerGeorgi Gerganov <redacted>
Sat, 13 Jan 2024 22:11:44 +0000 (00:11 +0200)
Co-authored-by: Bernhard Gstrein <redacted>
ggml.c

diff --git a/ggml.c b/ggml.c
index 6dbd7626c9e2376ebdc5ed0ebf6c82d7b3b33890..de6ef34bdde59cb216ffdd1b524c9eaf323fb0b6 100644 (file)
--- a/ggml.c
+++ b/ggml.c
@@ -19184,7 +19184,7 @@ void gguf_free(struct gguf_context * ctx) {
 
     if (ctx->kv) {
         // free string memory - not great..
-        for (uint32_t i = 0; i < ctx->header.n_kv; ++i) {
+        for (uint64_t i = 0; i < ctx->header.n_kv; ++i) {
             struct gguf_kv * kv = &ctx->kv[i];
 
             if (kv->key.data) {
@@ -19200,7 +19200,7 @@ void gguf_free(struct gguf_context * ctx) {
             if (kv->type == GGUF_TYPE_ARRAY) {
                 if (kv->value.arr.data) {
                     if (kv->value.arr.type == GGUF_TYPE_STRING) {
-                        for (uint32_t j = 0; j < kv->value.arr.n; ++j) {
+                        for (uint64_t j = 0; j < kv->value.arr.n; ++j) {
                             struct gguf_str * str = &((struct gguf_str *) kv->value.arr.data)[j];
                             if (str->data) {
                                 free(str->data);
@@ -19216,7 +19216,7 @@ void gguf_free(struct gguf_context * ctx) {
     }
 
     if (ctx->infos) {
-        for (uint32_t i = 0; i < ctx->header.n_tensors; ++i) {
+        for (uint64_t i = 0; i < ctx->header.n_tensors; ++i) {
             struct gguf_tensor_info * info = &ctx->infos[i];
 
             if (info->name.data) {