Fix overflowing on methods that take an offset as argument
This commit is contained in:
parent
c4969dfa4e
commit
36c91c7a4a
1 changed files with 2 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue