Fix NPE in DecryptExternal when reading lines

This commit is contained in:
Paul Schaub 2024-09-19 20:00:30 +02:00
parent ed9fb31549
commit 61f3bf14c5
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()
}