Store Smtp.error as Option<String>

Without this change, when SMTP password is incorrect,
as_str(sock.error) is called with a null pointer,
and as_str panics.

Now it does not crash when the error is not set.
This commit is contained in:
Alexander Krotov
2019-09-05 05:28:57 +03:00
parent f78f0079c1
commit c8d945db56
2 changed files with 5 additions and 5 deletions

View File

@@ -12,7 +12,7 @@ pub struct Smtp {
transport_connected: bool,
/// Email address we are sending from.
from: Option<EmailAddress>,
pub error: *mut libc::c_char,
pub error: Option<String>,
}
impl Smtp {
@@ -22,7 +22,7 @@ impl Smtp {
transport: None,
transport_connected: false,
from: None,
error: std::ptr::null_mut(),
error: None,
}
}