vad : reject n_encoder_layers other than 4 in model load (#4064)

n_encoder_layers is read from the VAD model file and three channel and
kernel arrays are sized to it, but the encoder graph is hardcoded to four
layers and indexes those arrays at [0..3]. A value below 4 reads past the
allocation, so reject anything other than 4 at the point of the read.
This commit is contained in:
Abir Deol
2026-09-22 07:23:38 +02:00
committed by GitHub
parent 307869af28
commit a44e078459
+5
View File
@@ -4947,6 +4947,11 @@ struct whisper_vad_context * whisper_vad_init_with_params(
{
read_safe(loader, hparams.n_encoder_layers);
if (hparams.n_encoder_layers != 4) {
WHISPER_LOG_ERROR("%s: invalid n_encoder_layers %d in VAD model file (expected 4)\n", __func__, hparams.n_encoder_layers);
return nullptr;
}
hparams.encoder_in_channels = new int32_t[hparams.n_encoder_layers];
hparams.encoder_out_channels = new int32_t[hparams.n_encoder_layers];
hparams.kernel_sizes = new int32_t[hparams.n_encoder_layers];