Skip to content

Commit 288bf19

Browse files
committed
Vector index access check for overflow
1 parent 548b9ca commit 288bf19

File tree

1 file changed

+5
-1
lines changed
  • src/AudioTools/CoreAudio/AudioBasic/Collections

1 file changed

+5
-1
lines changed

src/AudioTools/CoreAudio/AudioBasic/Collections/Vector.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,14 @@ class Vector {
254254

255255
T &operator[](int index) {
256256
assert(p_data != nullptr);
257+
assert(index < len);
257258
return p_data[index];
258259
}
259260

260-
T &operator[](const int index) const { return p_data[index]; }
261+
T &operator[](const int index) const {
262+
assert(index < len);
263+
return p_data[index];
264+
}
261265

262266
bool resize(int newSize, T value) {
263267
if (resize(newSize)) {

0 commit comments

Comments
 (0)