Skip to content

Cannot parse an empty data source #20

@IonutNegru87

Description

@IonutNegru87

In the scenario where the data source is empty the library crashes throwing Method java.lang.IndexOutOfBoundsException exception.

Code used to test this:

assertNull(BerTlv.parse("".toByteArray()))

I think this can be easily fixed by this change in the BerTlv.java class:

@JvmStatic
fun parse(data: ByteArray): BerTlv {
      if (data.isNotEmpty()) {
        return parseList(ByteBuffer.wrap(data), true)[0]
    } else {
        null
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions