]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
whisper : fix bug in token sampling logic
authorGeorgi Gerganov <redacted>
Fri, 7 Oct 2022 21:14:05 +0000 (00:14 +0300)
committerGeorgi Gerganov <redacted>
Sat, 8 Oct 2022 06:02:41 +0000 (09:02 +0300)
Could overflow buffer

whisper.cpp

index 9913ab6abc2e87118d371cc5ba38c0c567f6650f..cb15b986844db941755579e9da8c473e9edbc06e 100644 (file)
@@ -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--;