mirror of
https://github.com/ggml-org/whisper.cpp.git
synced 2026-09-30 03:21:18 +02:00
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:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user