Skip to content

Commit 2a61e81

Browse files
committed
fix map size regression
1 parent 9986e7b commit 2a61e81

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

formats/cbor/commonMain/src/kotlinx/serialization/cbor/internal/Decoder.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ internal class CborParser(private val input: ByteArrayInput, private val verifyO
180180

181181
override fun isNull() = (curByte == NULL || curByte == EMPTY_MAP || curByte == -1)
182182

183-
// Add this method to CborParser class
184183
private fun readUnsignedValueFromAdditionalInfo(additionalInfo: Int): Long {
185184
return when (additionalInfo) {
186185
in 0..23 -> additionalInfo.toLong()
@@ -197,7 +196,7 @@ internal class CborParser(private val input: ByteArrayInput, private val verifyO
197196
}
198197
}
199198

200-
fun nextTag(): ULong {
199+
internal fun nextTag(): ULong {
201200
if ((curByte shr 5) != 6) {
202201
throw CborDecodingException("Expected tag (major type 6), got major type ${curByte shr 5}")
203202
}
@@ -717,7 +716,7 @@ internal class StructuredCborParser(internal val element: CborElement, private v
717716
private class CborMapReader(cbor: Cbor, decoder: CborParserInterface) : CborListReader(cbor, decoder) {
718717
override fun skipBeginToken(objectTags: ULongArray?) =
719718
setSize(parser.startMap(tags?.let { if (objectTags == null) it else ulongArrayOf(*it, *objectTags) }
720-
?: objectTags))
719+
?: objectTags) * 2)
721720
}
722721

723722
private open class CborListReader(cbor: Cbor, decoder: CborParserInterface) : CborReader(cbor, decoder) {

formats/cbor/commonTest/src/kotlinx/serialization/cbor/SampleClasses.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ data class NullableByteString(
7373
@ByteString val byteString: ByteArray?
7474
) {
7575
override fun equals(other: Any?): Boolean {
76-
return toString() == other.toString()
77-
/*
76+
7877
if (this === other) return true
7978
if (other == null || this::class != other::class) return false
8079

@@ -85,7 +84,7 @@ data class NullableByteString(
8584
if (!byteString.contentEquals(other.byteString)) return false
8685
} else if (other.byteString != null) return false
8786

88-
return true*/
87+
return true
8988
}
9089

9190
override fun hashCode(): Int {

0 commit comments

Comments
 (0)