mirror of
https://github.com/isar/rusqlite.git
synced 2025-09-16 12:42:18 +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:
@@ -14,6 +14,10 @@ impl RawStatement {
|
||||
RawStatement(stmt, tail)
|
||||
}
|
||||
|
||||
pub fn is_null(&self) -> bool {
|
||||
self.0.is_null()
|
||||
}
|
||||
|
||||
pub unsafe fn ptr(&self) -> *mut ffi::sqlite3_stmt {
|
||||
self.0
|
||||
}
|
||||
@@ -95,8 +99,12 @@ impl RawStatement {
|
||||
unsafe { ffi::sqlite3_clear_bindings(self.0) }
|
||||
}
|
||||
|
||||
pub fn sql(&self) -> &CStr {
|
||||
unsafe { CStr::from_ptr(ffi::sqlite3_sql(self.0)) }
|
||||
pub fn sql(&self) -> Option<&CStr> {
|
||||
if self.0.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { CStr::from_ptr(ffi::sqlite3_sql(self.0)) })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn finalize(mut self) -> c_int {
|
||||
|
Reference in New Issue
Block a user