diff --git a/src/cborparser.c b/src/cborparser.c index c6a1b762..74d91a30 100644 --- a/src/cborparser.c +++ b/src/cborparser.c @@ -203,10 +203,13 @@ static CborError preparse_value(CborValue *it) it->extra = 0; /* read up to 16 bits into it->extra */ - if (bytesNeeded <= 2) { + if (bytesNeeded == 1) { + uint8_t extra; + read_bytes_unchecked(it, &extra, 1, bytesNeeded); + it->extra = extra; + } else if (bytesNeeded == 2) { read_bytes_unchecked(it, &it->extra, 1, bytesNeeded); - if (bytesNeeded == 2) - it->extra = cbor_ntohs(it->extra); + it->extra = cbor_ntohs(it->extra); } else { cbor_static_assert(CborIteratorFlag_IntegerValueTooLarge == (Value32Bit & 3)); cbor_static_assert((CborIteratorFlag_IntegerValueIs64Bit |