ggerganov / whisper.cpp

Port of OpenAI's Whisper model in C/C++
MIT License
35.38k stars 3.61k forks source link

bug report: index overflow cause crash #2504

Closed Josscii closed 1 week ago

Josscii commented 1 week ago

https://github.com/ggerganov/whisper.cpp/blob/a5abfe6a90495f7bf19fe70d016ecc255e97359c/src/whisper.cpp#L7022

j is compared with ns, which seems wrong, it should less than n, not ns.

Josscii commented 1 week ago

I do transcribe with turbo model, and it sometimes crash on this line

Josscii commented 1 week ago

@ggerganov

ggerganov commented 1 week ago

Thanks for finding this. Would you like to submit a PR?

Josscii commented 1 week ago

I can submit a pr, but I'm don't have a good understanding of the code, I only debuged it here, I'm afraid I would break some code

ggerganov commented 1 week ago

The fix is correct. ns is the number of samples, while the j iterator loops over the tokens, not the samples. This check is needed to guarantee that we don't do out-of-bounds access in the tokens array.

Josscii commented 1 week ago

Thanks for your explaination, I'll submit a pr