Fix queue accessing past end (Clang 20 GLIBC warning)

This commit is contained in:
Wilson Snyder 2025-03-27 19:00:43 -04:00
parent d26d62a176
commit 40acac1c57
1 changed files with 5 additions and 3 deletions

View File

@ -621,11 +621,13 @@ public:
T_Value& atWriteAppend(int32_t index) {
// cppcheck-suppress variableScope
static thread_local T_Value t_throwAway;
if (VL_UNLIKELY(index < 0 || index > m_deque.size())) {
if (VL_UNLIKELY(index < 0 || index >= m_deque.size())) {
if (index == m_deque.size()) {
push_back(atDefault());
return m_deque[index];
}
t_throwAway = atDefault();
return t_throwAway;
} else if (VL_UNLIKELY(index == m_deque.size())) {
push_back(atDefault());
}
return m_deque[index];
}