if in doubt, prefer unwrap_or_default()

if the past we had lots of crashes because of unexpected unwrap failures,
mostly related to string.
this commit avoids them eg. for string-conversions that may panic
eg. when encountering a null-byte or by logical programming errors
where an object is assumed to be set but is not under unexpected circumstances.
This commit is contained in:
B. Petersen
2019-10-04 00:05:14 +02:00
parent 93f0f5ccae
commit 477af413c6
28 changed files with 83 additions and 83 deletions

View File

@@ -695,7 +695,7 @@ impl<'a> MimeFactory<'a> {
Ok(())
},
)
.unwrap();
.unwrap_or_default();
let command = factory.msg.param.get_cmd();
let msg = &factory.msg;
@@ -900,7 +900,7 @@ fn build_body_file(
let mime_sub = mailmime_new_empty(content, mime_fields);
let abs_path = dc_get_abs_path(context, path_filename)
.to_c_string()
.unwrap();
.unwrap_or_default();
mailmime_set_body_file(mime_sub, dc_strdup(abs_path.as_ptr()));
Ok((mime_sub, filename_to_send))
}