From 81313a35aedc85c5fa98cd89b2f689d304f007af Mon Sep 17 00:00:00 2001 From: Xuan Son Nguyen Date: Thu, 25 Jun 2026 18:54:57 +0200 Subject: [PATCH] type check for get_arr_int --- tools/mtmd/clip.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/mtmd/clip.cpp b/tools/mtmd/clip.cpp index 0b220af6fd..d2226b3be1 100644 --- a/tools/mtmd/clip.cpp +++ b/tools/mtmd/clip.cpp @@ -3116,6 +3116,10 @@ struct clip_model_loader { } return; } + const auto type = gguf_get_arr_type(ctx_gguf.get(), i); + if (type != GGUF_TYPE_INT32) { + throw std::runtime_error(string_format("%s: array '%s' has type %d, expected %d (GGUF_TYPE_INT32)\n", __func__, key.c_str(), type, GGUF_TYPE_INT32)); + } const size_t n = gguf_get_arr_n(ctx_gguf.get(), i); if (n > (size_t) std::numeric_limits::max()) { throw std::runtime_error(string_format("%s: array '%s' is too large (%zu elements)\n", __func__, key.c_str(), n));