Skip to content

Commit b7346e7

Browse files
dfa1claude
andcommitted
fix(reader): restore long cast in Pco preDeltaN clamp (S2184)
Removing the (long) cast in 04cab70 turned `nRemaining - deltaOrder` into an int subtraction widened only afterward for Math.clamp(long,..), risking int overflow — SonarCloud flagged it as bug S2184. The cast was load-bearing, not redundant as S1905 claimed; restore it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a426c1d commit b7346e7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

reader/src/main/java/io/github/dfa1/vortex/reader/decode/PcoEncodingDecoder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ private static void decodeIntMultPage(
290290

291291
while (nRemaining > 0) {
292292
int batchN = Math.min(nRemaining, PcoTansDecoder.BATCH_N);
293-
int primaryPreDeltaN = (int) Math.clamp(nRemaining - deltaOrder, 0, batchN);
294-
int secondaryPreDeltaN = (int) Math.clamp(nRemaining - secondaryDeltaOrder, 0, batchN);
293+
int primaryPreDeltaN = (int) Math.clamp((long) nRemaining - deltaOrder, 0, batchN);
294+
int secondaryPreDeltaN = (int) Math.clamp((long) nRemaining - secondaryDeltaOrder, 0, batchN);
295295

296296
primaryTans.decodeBatch(pageReader, primaryStateIdxs, primaryPreDeltaN,
297297
batchLowersP, batchOffsetBitsP, rawMults, primaryPos);

0 commit comments

Comments
 (0)