summaryrefslogtreecommitdiff
path: root/ggml.c
diff options
context:
space:
mode:
authortexmex76 <40733439+texmex76@users.noreply.github.com>2024-01-13 17:06:20 +0100
committerGitHub <noreply@github.com>2024-01-13 18:06:20 +0200
commitc30b1ef39aeba497a943416d2897d69fee055b96 (patch)
treea785030a8a356a68bb095e87330262f1b76bd63a /ggml.c
parentb38b5e93ae31019e87f692b69d27124eae6aac02 (diff)
gguf : fix potential infinite for-loop (#4600)
Co-authored-by: Bernhard Gstrein <gstrein@informatik.uni-freiburg.de>
Diffstat (limited to 'ggml.c')
-rw-r--r--ggml.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ggml.c b/ggml.c
index 6dbd7626..de6ef34b 100644
--- 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) {