From 332c9d77fe1671b9a93975d80c712ee7f2e154b3 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 9913ab6..cb15b98 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--;