Merge pull request #117151 from Brogolem35/rb_overflow_fix

`RingBuffer`: Fix overreading on methods that take an offset as an argument
This commit is contained in:
Thaddeus Crews 2026-03-12 09:03:44 -05:00
commit a8e37fc010
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC

View file

@ -78,7 +78,7 @@ public:
int copy(T *p_buf, int p_offset, int p_size) const {
int left = data_left();
if ((p_offset + p_size) > left) {
p_size -= left - p_offset;
p_size = left - p_offset;
if (p_size <= 0) {
return 0;
}
@ -104,7 +104,7 @@ public:
int find(const T &t, int p_offset, int p_max_size) const {
int left = data_left();
if ((p_offset + p_max_size) > left) {
p_max_size -= left - p_offset;
p_max_size = left - p_offset;
if (p_max_size <= 0) {
return 0;
}