mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 21:36:30 +03:00
Fix bugs (#93)
* fix(repl): pass null pointer instead of empty string * fix(peerstate): ensure load and store to the db works
This commit is contained in:
committed by
Lars-Magnus Skog
parent
0d51c7dd2e
commit
d033667433
14
src/key.rs
14
src/key.rs
@@ -99,21 +99,17 @@ impl Key {
|
||||
match res {
|
||||
Ok(key) => Some(key),
|
||||
Err(err) => {
|
||||
eprintln!("Invalid key bytes: {:?}\n{}", err, hex::encode(bytes));
|
||||
eprintln!("Invalid key bytes: {:?}", err);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_binary(
|
||||
data: *const libc::c_void,
|
||||
len: libc::c_int,
|
||||
key_type: KeyType,
|
||||
) -> Option<Self> {
|
||||
pub fn from_binary(data: *const u8, len: libc::c_int, key_type: KeyType) -> Option<Self> {
|
||||
assert!(!data.is_null(), "missing data");
|
||||
assert!(len > 0);
|
||||
|
||||
let bytes = unsafe { slice::from_raw_parts(data as *const u8, len as usize) };
|
||||
let bytes = unsafe { slice::from_raw_parts(data, len as usize) };
|
||||
Self::from_slice(bytes, key_type)
|
||||
}
|
||||
|
||||
@@ -124,9 +120,7 @@ impl Key {
|
||||
) -> Option<Self> {
|
||||
assert!(!stmt.is_null(), "missing statement");
|
||||
|
||||
let data = unsafe {
|
||||
sqlite3_column_blob(stmt, index) as *mut libc::c_uchar as *const libc::c_void
|
||||
};
|
||||
let data = unsafe { sqlite3_column_blob(stmt, index) as *const u8 };
|
||||
let len = unsafe { sqlite3_column_bytes(stmt, index) };
|
||||
|
||||
Self::from_binary(data, len, key_type)
|
||||
|
||||
Reference in New Issue
Block a user