Fix a rare crash on startup (#19922)

Mikayla Maki created

Release Notes:

- Fixed a rare crash that could happen when certain SQL statements are
prepared

Change summary

crates/sqlez/src/statement.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Detailed changes

crates/sqlez/src/statement.rs 🔗

@@ -58,13 +58,13 @@ impl<'a> Statement<'a> {
                     &mut remaining_sql_ptr,
                 );
 
-                remaining_sql = CStr::from_ptr(remaining_sql_ptr);
-                statement.raw_statements.push(raw_statement);
-
                 connection.last_error().with_context(|| {
                     format!("Prepare call failed for query:\n{}", query.as_ref())
                 })?;
 
+                remaining_sql = CStr::from_ptr(remaining_sql_ptr);
+                statement.raw_statements.push(raw_statement);
+
                 if !connection.can_write() && sqlite3_stmt_readonly(raw_statement) == 0 {
                     let sql = CStr::from_ptr(sqlite3_sql(raw_statement));