From ab6694ca6ab07bc0c461683a3045970a9f81c3d2 Mon Sep 17 00:00:00 2001 From: rnentjes Date: Mon, 16 Jun 2025 19:46:04 +0200 Subject: [PATCH] Fix slice bounds check in `SlicedByteArray` and release version 0.3.3. --- build.gradle.kts | 2 +- src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6dbbfc5..d55fc32 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "nl.astraeus" -version = "0.3.3-SNAPSHOT" +version = "0.3.3" repositories { mavenCentral() diff --git a/src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt b/src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt index b39f59a..4375086 100644 --- a/src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt +++ b/src/commonMain/kotlin/nl/astraeus/tba/SlicedByteArray.kt @@ -188,7 +188,7 @@ class SlicedByteArray( fun slice(offset: Int, length: Int): SlicedByteArray { check(offset >= 0) { "Offset must be non-negative" } check(length >= 0) { "Length must be non-negative" } - check(offset + length <= this.length) { "Offset + length exceeds array bounds (offset: $offset, length: $length, array length: ${this.length})" } + check(offset + length <= this.data.size) { "Offset + length exceeds array bounds (offset: $offset, length: $length, array length: ${this.data.size})" } return SlicedByteArray(data, this.offset + offset, length) }