aboutsummaryrefslogtreecommitdiff
path: root/jgvariant-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'jgvariant-core/src')
-rw-r--r--jgvariant-core/src/main/java/eu/mulk/jgvariant/core/Decoder.java4
1 files changed, 2 insertions, 2 deletions
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<T> {
// 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<T> {
}
// 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);
}