Skip to content

Commit 60c0be6

Browse files
authored
whisper : add check for ttype in whisper and parakeet (#4091)
1 parent 6e4ab85 commit 60c0be6

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎src/parakeet.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,11 @@ static bool parakeet_model_load(struct parakeet_model_loader * loader, parakeet_
14441444
return false;
14451445
}
14461446

1447+
if (ttype < 0 || ttype >= GGML_TYPE_COUNT) {
1448+
PARAKEET_LOG_ERROR("%s: invalid ttype %d in model file (expected 0 <= ttype < %d)\n", __func__, ttype, GGML_TYPE_COUNT);
1449+
return false;
1450+
}
1451+
14471452
int32_t nelements = 1;
14481453
int32_t ne[4] = { 1, 1, 1, 1 };
14491454
for (int i = 0; i < n_dims; ++i) {

‎src/whisper.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,10 @@ static bool whisper_model_load(struct whisper_model_loader * loader, whisper_con
18961896
return false;
18971897
}
18981898

1899+
if (ttype < 0 || ttype >= GGML_TYPE_COUNT) {
1900+
WHISPER_LOG_ERROR("%s: invalid ttype %d in model file (expected 0 <= ttype < %d)\n", __func__, ttype, GGML_TYPE_COUNT);
1901+
return false;
1902+
}
18991903

19001904
int32_t nelements = 1;
19011905
int32_t ne[4] = { 1, 1, 1, 1 };
@@ -5172,6 +5176,10 @@ struct whisper_vad_context * whisper_vad_init_with_params(
51725176
return nullptr;
51735177
}
51745178

5179+
if (ttype < 0 || ttype >= GGML_TYPE_COUNT) {
5180+
WHISPER_LOG_ERROR("%s: invalid ttype %d in model file (expected 0 <= ttype < %d)\n", __func__, ttype, GGML_TYPE_COUNT);
5181+
return nullptr;
5182+
}
51755183

51765184
int32_t nelements = 1;
51775185
int32_t ne[4] = { 1, 1, 1, 1 };

0 commit comments

Comments
 (0)