Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.15.0
Description
The below code is the current implementation of HSCAN in RedisHash. When the value of count passed to this method is greater than Integer.MAX_VALUE / 2 the condition of the while loop suffers from integer overflow and the loop does not execute correctly.
public ImmutablePair<Integer, List<byte[]>> hscan(Pattern matchPattern, int count, int cursor) { ArrayList<byte[]> resultList = new ArrayList<>(count + 2); do { cursor = hash.scan(cursor, 1, (list, key, value) -> addIfMatching(matchPattern, list, key, value), resultList); } while (cursor != 0 && resultList.size() < (count * 2)); return new ImmutablePair<>(cursor, resultList);
This could be fixed by changing the type of resultList to List<ImmutablePair<byte[] byte[]>> and modifying the addIfMatching() method to populate the list with {{ImmutablePair}}s of keys and values rather than a single continuous list of interleaved keys and values.
Attachments
Issue Links
- links to