Fix NPE in DecryptExternal when reading lines

This commit is contained in:
Paul Schaub 2024-09-19 20:00:30 +02:00
parent 1df5747549
commit 4388f00dc0
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -108,8 +108,8 @@ class DecryptExternal(
finish(process)
val sessionKeyOutIn = FileInputStream(sessionKeyOut)
var line = readString(sessionKeyOutIn)
val sessionKey = SessionKey.fromString(line.trim { it <= ' ' })
var line: String? = readString(sessionKeyOutIn)
val sessionKey = line?.let { l -> SessionKey.fromString(l.trim { it <= ' ' }) }
sessionKeyOutIn.close()
sessionKeyOut.delete()
@ -118,7 +118,7 @@ class DecryptExternal(
val verifyOutIn = FileInputStream(verifyOut)
val reader = BufferedReader(InputStreamReader(verifyOutIn))
while (reader.readLine().also { line = it } != null) {
verifications.add(Verification.fromString(line.trim()))
line?.let { verifications.add(Verification.fromString(it.trim())) }
}
reader.close()
}