From 47ec0e1d8fbba952ec63a0557751b35076d650d1 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 7 Nov 2020 11:54:59 +0100 Subject: [PATCH] Fix create_collation The xDestroy callback is not called if the sqlite3_create_collation_v2() function fails. --- src/collation.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/collation.rs b/src/collation.rs index 5c2d059..2084514 100644 --- a/src/collation.rs +++ b/src/collation.rs @@ -96,7 +96,12 @@ impl InnerConnection { Some(free_boxed_value::), ) }; - self.decode_result(r) + let res = self.decode_result(r); + // The xDestroy callback is not called if the sqlite3_create_collation_v2() function fails. + if res.is_err() { + drop(unsafe { Box::from_raw(boxed_f) }); + } + res } fn collation_needed(