From dbe941f2b9b67735677cdd264dab8d0d761a8213 Mon Sep 17 00:00:00 2001 From: Rohit Mahesh <74331568+rohitmahesh1@users.noreply.github.com> Date: Sat, 11 Jul 2026 13:02:44 -0500 Subject: [PATCH] gguf : reject empty metadata keys (llama/24917) --- ggml/src/gguf.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ggml/src/gguf.cpp b/ggml/src/gguf.cpp index 5e1986182..c3ffa1a13 100644 --- a/ggml/src/gguf.cpp +++ b/ggml/src/gguf.cpp @@ -557,6 +557,10 @@ static struct gguf_context * gguf_init_from_reader(const struct gguf_reader & gr GGML_LOG_ERROR("%s: encountered bad_alloc error while reading key %" PRIi64 "\n", __func__, i); ok = false; } + if (ok && key.empty()) { + GGML_LOG_ERROR("%s: key %" PRIi64 " is empty\n", __func__, i); + ok = false; + } for (size_t j = 0; ok && j < ctx->kv.size(); ++j) { if (key == ctx->kv[j].key) { GGML_LOG_ERROR("%s: duplicate key '%s' for tensors %zu and %" PRIi64 " \n", __func__, key.c_str(), j, i);