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:
gwenn
2019-10-29 19:24:18 +01:00
parent 31139bbe9f
commit edfd7658c3
5 changed files with 41 additions and 7 deletions

View File

@@ -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