8322417: Console read line with zero out should zero out when throwing exception

Reviewed-by: mbaesken, stuefe, naoto
This commit is contained in:
Goetz Lindenmaier 2023-12-20 08:01:08 +00:00
parent 7db69e6a12
commit 2f917bff5c

@ -119,8 +119,17 @@ public final class JdkConsoleImpl implements JdkConsole {
else
ioe.addSuppressed(x);
}
if (ioe != null)
if (ioe != null) {
java.util.Arrays.fill(passwd, ' ');
try {
if (reader instanceof LineReader lr) {
lr.zeroOut();
}
} catch (IOException x) {
// ignore
}
throw ioe;
}
}
pw.println();
}