From 60c0be6ac8fa71b1a2ae2dd938a31a34a508e774 Mon Sep 17 00:00:00 2001 From: Vincenzo Reina Date: Fri, 2 Oct 2026 14:21:13 +0100 Subject: [PATCH] whisper : add check for ttype in whisper and parakeet (#4091) --- src/parakeet.cpp | 5 +++++ src/whisper.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/parakeet.cpp b/src/parakeet.cpp index 1b11bee11..ed6638299 100644 --- a/src/parakeet.cpp +++ b/src/parakeet.cpp @@ -1444,6 +1444,11 @@ static bool parakeet_model_load(struct parakeet_model_loader * loader, parakeet_ return false; } + if (ttype < 0 || ttype >= GGML_TYPE_COUNT) { + PARAKEET_LOG_ERROR("%s: invalid ttype %d in model file (expected 0 <= ttype < %d)\n", __func__, ttype, GGML_TYPE_COUNT); + return false; + } + int32_t nelements = 1; int32_t ne[4] = { 1, 1, 1, 1 }; for (int i = 0; i < n_dims; ++i) { diff --git a/src/whisper.cpp b/src/whisper.cpp index dd8bd9378..1675f33ac 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -1896,6 +1896,10 @@ static bool whisper_model_load(struct whisper_model_loader * loader, whisper_con return false; } + if (ttype < 0 || ttype >= GGML_TYPE_COUNT) { + WHISPER_LOG_ERROR("%s: invalid ttype %d in model file (expected 0 <= ttype < %d)\n", __func__, ttype, GGML_TYPE_COUNT); + return false; + } int32_t nelements = 1; int32_t ne[4] = { 1, 1, 1, 1 }; @@ -5172,6 +5176,10 @@ struct whisper_vad_context * whisper_vad_init_with_params( return nullptr; } + if (ttype < 0 || ttype >= GGML_TYPE_COUNT) { + WHISPER_LOG_ERROR("%s: invalid ttype %d in model file (expected 0 <= ttype < %d)\n", __func__, ttype, GGML_TYPE_COUNT); + return nullptr; + } int32_t nelements = 1; int32_t ne[4] = { 1, 1, 1, 1 };