mirror of
https://github.com/chatmail/core.git
synced 2026-05-20 15:26:30 +03:00
fix: do not generate ptrs inside map
This commit is contained in:
@@ -848,13 +848,16 @@ pub unsafe fn dc_get_contact_encrinfo(
|
|||||||
fingerprint_other_unverified,
|
fingerprint_other_unverified,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
let c_addr = peerstate.addr.as_ref().map(to_cstring);
|
let c_addr = peerstate.addr.as_ref().map(to_cstring).unwrap_or_default();
|
||||||
|
let addr_ptr = if peerstate.addr.is_some() {
|
||||||
|
c_addr.as_ptr()
|
||||||
|
} else {
|
||||||
|
std::ptr::null()
|
||||||
|
};
|
||||||
|
|
||||||
cat_fingerprint(
|
cat_fingerprint(
|
||||||
&mut ret,
|
&mut ret,
|
||||||
c_addr
|
addr_ptr,
|
||||||
.map(|a| a.as_ptr())
|
|
||||||
.unwrap_or_else(|| std::ptr::null()),
|
|
||||||
fingerprint_other_verified,
|
fingerprint_other_verified,
|
||||||
fingerprint_other_unverified,
|
fingerprint_other_unverified,
|
||||||
);
|
);
|
||||||
|
|||||||
15
src/dc_qr.rs
15
src/dc_qr.rs
@@ -245,13 +245,20 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc
|
|||||||
if addr.is_null() || invitenumber.is_null() || auth.is_null() {
|
if addr.is_null() || invitenumber.is_null() || auth.is_null() {
|
||||||
if let Some(peerstate) = peerstate {
|
if let Some(peerstate) = peerstate {
|
||||||
(*qr_parsed).state = 210i32;
|
(*qr_parsed).state = 210i32;
|
||||||
let c_addr = peerstate.addr.as_ref().map(to_cstring);
|
let c_addr = peerstate
|
||||||
|
.addr
|
||||||
|
.as_ref()
|
||||||
|
.map(to_cstring)
|
||||||
|
.unwrap_or_default();
|
||||||
|
let addr_ptr = if peerstate.addr.is_some() {
|
||||||
|
c_addr.as_ptr()
|
||||||
|
} else {
|
||||||
|
std::ptr::null()
|
||||||
|
};
|
||||||
(*qr_parsed).id = dc_add_or_lookup_contact(
|
(*qr_parsed).id = dc_add_or_lookup_contact(
|
||||||
context,
|
context,
|
||||||
0 as *const libc::c_char,
|
0 as *const libc::c_char,
|
||||||
c_addr
|
addr_ptr,
|
||||||
.map(|a| a.as_ptr())
|
|
||||||
.unwrap_or_else(|| std::ptr::null()),
|
|
||||||
0x80i32,
|
0x80i32,
|
||||||
0 as *mut libc::c_int,
|
0 as *mut libc::c_int,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -543,22 +543,17 @@ impl<'a> Peerstate<'a> {
|
|||||||
as *const u8 as *const libc::c_char)
|
as *const u8 as *const libc::c_char)
|
||||||
};
|
};
|
||||||
|
|
||||||
let addr_c = self.addr.as_ref().map(|fp| to_cstring(fp));
|
let c_addr = self.addr.as_ref().map(to_cstring).unwrap_or_default();
|
||||||
|
let addr_ptr = if self.addr.is_some() {
|
||||||
|
c_addr.as_ptr()
|
||||||
|
} else {
|
||||||
|
std::ptr::null()
|
||||||
|
};
|
||||||
|
|
||||||
unsafe { sqlite3_bind_int64(stmt, 1, self.last_seen as sqlite3_int64) };
|
unsafe { sqlite3_bind_int64(stmt, 1, self.last_seen as sqlite3_int64) };
|
||||||
unsafe { sqlite3_bind_int64(stmt, 2, self.last_seen_autocrypt as sqlite3_int64) };
|
unsafe { sqlite3_bind_int64(stmt, 2, self.last_seen_autocrypt as sqlite3_int64) };
|
||||||
unsafe { sqlite3_bind_int64(stmt, 3, self.gossip_timestamp as sqlite3_int64) };
|
unsafe { sqlite3_bind_int64(stmt, 3, self.gossip_timestamp as sqlite3_int64) };
|
||||||
unsafe {
|
unsafe { sqlite3_bind_text(stmt, 4, addr_ptr, -1, SQLITE_TRANSIENT()) };
|
||||||
sqlite3_bind_text(
|
|
||||||
stmt,
|
|
||||||
4,
|
|
||||||
addr_c
|
|
||||||
.map(|addr| addr.as_ptr())
|
|
||||||
.unwrap_or_else(|| std::ptr::null()),
|
|
||||||
-1,
|
|
||||||
SQLITE_TRANSIENT(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
if unsafe { sqlite3_step(stmt) } == 101 {
|
if unsafe { sqlite3_step(stmt) } == 101 {
|
||||||
success = true;
|
success = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user