mirror of
https://github.com/isar/rusqlite.git
synced 2025-09-16 04:32:19 +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:
@@ -625,7 +625,11 @@ impl Into<RawStatement> for Statement<'_> {
|
||||
|
||||
impl fmt::Debug for Statement<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let sql = str::from_utf8(self.stmt.sql().to_bytes());
|
||||
let sql = if self.stmt.is_null() {
|
||||
Ok("")
|
||||
} else {
|
||||
str::from_utf8(self.stmt.sql().unwrap().to_bytes())
|
||||
};
|
||||
f.debug_struct("Statement")
|
||||
.field("conn", self.conn)
|
||||
.field("stmt", &self.stmt)
|
||||
|
Reference in New Issue
Block a user