From 147a1c19c1f7bfe8d0939618d3c8dc2bb4e59fb7 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 10 Dec 2023 20:54:33 +0100 Subject: Add more property-based tests and fix more bugs. Change-Id: I8deb1a7d75078c037714541d8f6f656052c2476c --- jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'jgvariant-core') diff --git a/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java b/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java index fcbb639..2121cfb 100644 --- a/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java +++ b/jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java @@ -364,7 +364,7 @@ public abstract class Decoder { // Determining the framing offset size requires trial and error. int framingOffsetSize; for (framingOffsetSize = 0;; framingOffsetSize = max(1, framingOffsetSize << 1)) { - if (elementsRelativeEnd + framingOffsetSize* framingOffsets.size() >= 1 << (8*framingOffsetSize)) { + if (elementsRelativeEnd + (long)framingOffsetSize * framingOffsets.size() >= 1L << (8*framingOffsetSize)) { continue; } @@ -457,7 +457,7 @@ public abstract class Decoder { } // Write the framing offsets. - int framingOffsetSize = computeFramingOffsetSize(byteWriter.position() - startOffset, framingOffsets); + int framingOffsetSize = max(1, computeFramingOffsetSize(byteWriter.position() - startOffset, framingOffsets)); for (var framingOffset : framingOffsets) { byteWriter.writeIntN(framingOffset, framingOffsetSize); } -- cgit v1.2.3