Fix panic at 'SQLite API not initialized or SQLite feature omitted'

`to_sqlite_error` needs `sqlite3_malloc`

```
sqlite> .log on
sqlite> .load target/debug/examples/libloadable_extension.so
Error: error during initialization: SQLite version mismatch: 3014000 < 3042000
```
This commit is contained in:
gwenn
2023-07-14 15:56:43 +02:00
parent c8858bbb68
commit f9d69410ef
5 changed files with 13 additions and 18 deletions

View File

@@ -25,7 +25,9 @@ pub extern "C" fn sqlite3_extension_init(
pz_err_msg: *mut *mut c_char,
p_api: *mut ffi::sqlite3_api_routines,
) -> c_int {
if let Err(err) = extension_init(db, p_api) {
if p_api.is_null() {
return ffi::SQLITE_ERROR;
} else if let Err(err) = extension_init(db, p_api) {
return unsafe { to_sqlite_error(&err, pz_err_msg) };
}
ffi::SQLITE_OK