diff --git a/deltachat-ffi/src/dc_array.rs b/deltachat-ffi/src/dc_array.rs index 36ee3fc0f..7c5d87a5e 100644 --- a/deltachat-ffi/src/dc_array.rs +++ b/deltachat-ffi/src/dc_array.rs @@ -39,6 +39,17 @@ impl dc_array_t { } } + pub(crate) fn get_marker(&self, index: usize) -> Option<&str> { + match self { + Self::MsgIds(_) => None, + Self::Chat(array) => None, + Self::Locations(array) => array + .get(index) + .and_then(|location| location.marker.as_deref()), + Self::Uint(_) => None, + } + } + pub(crate) fn get_location(&self, index: usize) -> &Location { if let Self::Locations(array) = self { &array[index] diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 7d9156dbc..c09fafb54 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -2068,7 +2068,7 @@ pub unsafe extern "C" fn dc_array_get_marker( return std::ptr::null_mut(); // NULL explicitly defined as "no markers" } - if let Some(s) = &(*array).get_location(index).marker { + if let Some(s) = (*array).get_marker(index) { s.strdup() } else { std::ptr::null_mut()