From 3d546ff8a46164724ac3018af8ae17b9d7498a5c Mon Sep 17 00:00:00 2001 From: Maas-Maarten Zeeman Date: Fri, 16 Dec 2016 11:14:33 +0100 Subject: [PATCH] Empty the command queue before destroying it. It could contain commands. Fixes a crash --- c_src/esqlite3_nif.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/c_src/esqlite3_nif.c b/c_src/esqlite3_nif.c index 1727ed6..3b46fdb 100644 --- a/c_src/esqlite3_nif.c +++ b/c_src/esqlite3_nif.c @@ -218,11 +218,13 @@ destruct_esqlite_connection(ErlNifEnv *env, void *arg) /* Wait for the thread to finish */ enif_thread_join(db->tid, NULL); + enif_thread_opts_destroy(db->opts); /* The thread has finished... now remove the command queue, and close - * the datbase (if it was still open). + * the database (if it was still open). */ + while(queue_has_item(db->commands)) command_destroy(queue_pop(db->commands)); queue_destroy(db->commands); if(db->db) {