From 36c91c7a4abde6823c2aae07895d0fb129fe27ca Mon Sep 17 00:00:00 2001 From: Brogolem35 Date: Fri, 6 Mar 2026 18:53:26 +0300 Subject: [PATCH] Fix overflowing on methods that take an offset as argument --- core/templates/ring_buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/templates/ring_buffer.h b/core/templates/ring_buffer.h index 9b00f4d0898..83d9b193173 100644 --- a/core/templates/ring_buffer.h +++ b/core/templates/ring_buffer.h @@ -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; }