Fix NPE in TextKeyReader if the input is invalid

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent a6fa7bf5b6
commit a02eb169f4
  1. 8
      archive/src/main/kotlin/org/openrs2/archive/key/TextKeyReader.kt

@ -7,10 +7,10 @@ public object TextKeyReader : KeyReader {
override fun read(input: InputStream): Sequence<XteaKey> { override fun read(input: InputStream): Sequence<XteaKey> {
val reader = input.bufferedReader() val reader = input.bufferedReader()
val k0 = reader.readLine().toIntOrNull() ?: return emptySequence() val k0 = reader.readLine()?.toIntOrNull() ?: return emptySequence()
val k1 = reader.readLine().toIntOrNull() ?: return emptySequence() val k1 = reader.readLine()?.toIntOrNull() ?: return emptySequence()
val k2 = reader.readLine().toIntOrNull() ?: return emptySequence() val k2 = reader.readLine()?.toIntOrNull() ?: return emptySequence()
val k3 = reader.readLine().toIntOrNull() ?: return emptySequence() val k3 = reader.readLine()?.toIntOrNull() ?: return emptySequence()
return sequenceOf(XteaKey(k0, k1, k2, k3)) return sequenceOf(XteaKey(k0, k1, k2, k3))
} }

Loading…
Cancel
Save