mirror of
https://github.com/isar/rusqlite.git
synced 2025-11-06 09:48:58 +08:00
Avoid relying on sqlite to justify str::from_utf8_unchecked
This commit is contained in:
committed by
Thom Chiovoloni
parent
1b27ce0541
commit
cf9b6e9ae2
@@ -69,9 +69,11 @@ impl Session<'_> {
|
||||
let boxed_filter: *mut F = p_arg as *mut F;
|
||||
let tbl_name = {
|
||||
let c_slice = CStr::from_ptr(tbl_str).to_bytes();
|
||||
str::from_utf8_unchecked(c_slice)
|
||||
str::from_utf8(c_slice)
|
||||
};
|
||||
if let Ok(true) = catch_unwind(|| (*boxed_filter)(tbl_name)) {
|
||||
if let Ok(true) =
|
||||
catch_unwind(|| (*boxed_filter)(tbl_name.expect("non-utf8 table name")))
|
||||
{
|
||||
1
|
||||
} else {
|
||||
0
|
||||
@@ -660,11 +662,11 @@ where
|
||||
let tuple: *mut (Option<F>, C) = p_ctx as *mut (Option<F>, C);
|
||||
let tbl_name = {
|
||||
let c_slice = CStr::from_ptr(tbl_str).to_bytes();
|
||||
str::from_utf8_unchecked(c_slice)
|
||||
str::from_utf8(c_slice)
|
||||
};
|
||||
match *tuple {
|
||||
(Some(ref filter), _) => {
|
||||
if let Ok(true) = catch_unwind(|| filter(tbl_name)) {
|
||||
if let Ok(true) = catch_unwind(|| filter(tbl_name.expect("illegal table name"))) {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
|
||||
Reference in New Issue
Block a user