mirror of
https://github.com/isar/rusqlite.git
synced 2025-10-16 08:12:24 +08:00
Segmentation fault on prepare_cached
with an empty query
With an empty query is prepared, sqlite3 returns no error but a null pointer. And then `sqlite3_sql` returns null. Which make `CStr::from_ptr` crash.
This commit is contained in:
@@ -90,9 +90,17 @@ impl InnerConnection {
|
||||
} else {
|
||||
let mut e = error_from_handle(db, r);
|
||||
if let Error::SqliteFailure(
|
||||
ffi::Error{code: ffi::ErrorCode::CannotOpen, extended_code: _}, Some(msg)) = e {
|
||||
ffi::Error {
|
||||
code: ffi::ErrorCode::CannotOpen,
|
||||
extended_code: _,
|
||||
},
|
||||
Some(msg),
|
||||
) = e
|
||||
{
|
||||
e = Error::SqliteFailure(
|
||||
ffi::Error::new(r), Some(format!("{}: {}", msg, c_path.to_string_lossy())));
|
||||
ffi::Error::new(r),
|
||||
Some(format!("{}: {}", msg, c_path.to_string_lossy())),
|
||||
);
|
||||
}
|
||||
ffi::sqlite3_close(db);
|
||||
e
|
||||
|
Reference in New Issue
Block a user