File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,7 +179,8 @@ bool FileReader::cmp(int pos, const char *s)
179179
180180bool FileReader::fillBuf (int pos, int len)
181181{
182- if (pos < 0 || len < 0 || len > (int )sizeof (buf) || pos > INT_MAX - (int )sizeof (buf)) {
182+ constexpr int bufSize = sizeof (buf);
183+ if (pos < 0 || len < 0 || len > bufSize || pos > INT_MAX - bufSize) {
183184 return false ;
184185 }
185186 if (pos >= bufPos && pos + len <= bufPos + bufLen) {
@@ -305,15 +306,16 @@ bool StreamReader::fillBuf(int pos, int len)
305306{
306307 int c;
307308
308- if (pos < 0 || len < 0 || len > (int )sizeof (buf) || pos > INT_MAX - (int )sizeof (buf)) {
309+ constexpr int bufSize = sizeof (buf);
310+ if (pos < 0 || len < 0 || len > bufSize || pos > INT_MAX - bufSize) {
309311 return false ;
310312 }
311313 if (pos < bufPos) {
312314 return false ;
313315 }
314316
315317 // if requested region will not fit in the current buffer...
316- if (pos + len > bufPos + ( int ) sizeof (buf) ) {
318+ if (pos + len > bufPos + bufSize ) {
317319
318320 // if the start of the requested data is already in the buffer, move
319321 // it to the start of the buffer
You can’t perform that action at this time.
0 commit comments