mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
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:
@@ -156,7 +156,7 @@ impl Job {
|
|||||||
let mut sock = context.smtp.lock().unwrap();
|
let mut sock = context.smtp.lock().unwrap();
|
||||||
if 0 == sock.send(context, recipients_list, body) {
|
if 0 == sock.send(context, recipients_list, body) {
|
||||||
sock.disconnect();
|
sock.disconnect();
|
||||||
self.try_again_later(-1i32, Some(as_str(sock.error)));
|
self.try_again_later(-1i32, sock.error.clone());
|
||||||
} else {
|
} else {
|
||||||
dc_delete_file(context, filename);
|
dc_delete_file(context, filename);
|
||||||
if 0 != self.foreign_id {
|
if 0 != self.foreign_id {
|
||||||
@@ -189,9 +189,9 @@ impl Job {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this value does not increase the number of tries
|
// this value does not increase the number of tries
|
||||||
fn try_again_later(&mut self, try_again: libc::c_int, pending_error: Option<&str>) {
|
fn try_again_later(&mut self, try_again: libc::c_int, pending_error: Option<String>) {
|
||||||
self.try_again = try_again;
|
self.try_again = try_again;
|
||||||
self.pending_error = pending_error.map(|s| s.to_string());
|
self.pending_error = pending_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub struct Smtp {
|
|||||||
transport_connected: bool,
|
transport_connected: bool,
|
||||||
/// Email address we are sending from.
|
/// Email address we are sending from.
|
||||||
from: Option<EmailAddress>,
|
from: Option<EmailAddress>,
|
||||||
pub error: *mut libc::c_char,
|
pub error: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Smtp {
|
impl Smtp {
|
||||||
@@ -22,7 +22,7 @@ impl Smtp {
|
|||||||
transport: None,
|
transport: None,
|
||||||
transport_connected: false,
|
transport_connected: false,
|
||||||
from: None,
|
from: None,
|
||||||
error: std::ptr::null_mut(),
|
error: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user