common : fix ub (#5530)

This commit is contained in:
Georgi Gerganov 2024-02-18 18:21:52 +02:00
parent 5d3de51f97
commit 1dcc3fde00
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735

View File

@ -1801,7 +1801,8 @@ void dump_kv_cache_view_seqs(const llama_kv_cache_view & view, int row_size) {
if (cs_curr[j] < 0) { continue; }
if (seqs.find(cs_curr[j]) == seqs.end()) {
if (seqs.size() + 1 >= sizeof(slot_chars)) { break; }
seqs[cs_curr[j]] = seqs.size();
const size_t sz = seqs.size();
seqs[cs_curr[j]] = sz;
}
}
if (seqs.size() + 1 >= sizeof(slot_chars)) { break; }