better bubble up DB errors and guard one unwrap() where a crash occured during integration test run

(and possibly also related to #633)
This commit is contained in:
holger krekel
2019-09-28 12:48:41 +02:00
parent a5cde0d137
commit feee340f4d
2 changed files with 7 additions and 11 deletions

View File

@@ -610,7 +610,7 @@ unsafe fn add_parts(
let icnt = mime_parser.parts.len(); let icnt = mime_parser.parts.len();
let mut txt_raw = None; let mut txt_raw = None;
let is_ok = context context
.sql .sql
.prepare( .prepare(
"INSERT INTO msgs \ "INSERT INTO msgs \
@@ -697,13 +697,10 @@ unsafe fn add_parts(
Ok(()) Ok(())
}, },
) )
.is_ok(); .map_err(|err| {
cleanup(mime_in_reply_to, mime_references);
if !is_ok { err
// i/o error - there is nothing more we can do - in other cases, we try to write at least an empty record })?;
cleanup(mime_in_reply_to, mime_references);
bail!("Cannot write DB.");
}
info!( info!(
context, context,

View File

@@ -1,7 +1,6 @@
//! End-to-end encryption support. //! End-to-end encryption support.
use std::collections::HashSet; use std::collections::HashSet;
use std::ffi::CStr;
use std::ptr; use std::ptr;
use std::str::FromStr; use std::str::FromStr;
@@ -479,8 +478,8 @@ fn update_gossip_peerstates(
if !optional_field.fld_name.is_null() if !optional_field.fld_name.is_null()
&& as_str(optional_field.fld_name) == "Autocrypt-Gossip" && as_str(optional_field.fld_name) == "Autocrypt-Gossip"
{ {
let value = unsafe { CStr::from_ptr(optional_field.fld_value).to_str().unwrap() }; let value = to_string_lossy(optional_field.fld_value);
let gossip_header = Aheader::from_str(value); let gossip_header = Aheader::from_str(&value);
if let Ok(ref header) = gossip_header { if let Ok(ref header) = gossip_header {
if recipients.is_none() { if recipients.is_none() {