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 };