From 38589177d2014c70e04cd93d178ab098333fa742 Mon Sep 17 00:00:00 2001 From: NovaliX Date: Tue, 12 Jul 2022 23:18:06 +0200 Subject: [PATCH] Fix a bug where the newline was not added when io error on reader-readline() occured --- src/rpassword/all.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rpassword/all.rs b/src/rpassword/all.rs index 5d5bde0..343c09d 100644 --- a/src/rpassword/all.rs +++ b/src/rpassword/all.rs @@ -188,11 +188,15 @@ mod windows { let hidden_input = HiddenInput::new(handle)?; - reader.read_line(&mut password)?; + let reader_return = reader.read_line(&mut password); // Newline for windows which otherwise prints on the same line. println!(); + if reader_return.is_err() { + return Err(reader_return.unwrap_err()); + } + std::mem::drop(hidden_input); super::fix_new_line(password.into_inner())