From 90513c3ac44453fddefbab7b5f1aafb688e8e979 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 8 Oct 2022 00:14:05 +0300 Subject: [PATCH] whisper : fix bug in token sampling logic Could overflow buffer --- whisper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whisper.cpp b/whisper.cpp index 9913ab6a..cb15b986 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -2470,7 +2470,7 @@ int whisper_full( result_all.push_back({ t0, t1, text }); } text = ""; - while (result_cur[i].id > whisper_token_beg(ctx) && i < (int) result_cur.size()) { + while (i < (int) result_cur.size() && result_cur[i].id > whisper_token_beg(ctx)) { i++; } i--;