From e873a49d99191ced94f4247a9b5ca608d9d01815 Mon Sep 17 00:00:00 2001 From: Nick Parker Date: Fri, 13 May 2016 16:28:34 -0500 Subject: [PATCH] Prevent deadlock of database mutex --- src/crypto.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/crypto.c b/src/crypto.c index 2f3ee4e..2241fb8 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -365,7 +365,11 @@ int sqlite3CodecAttach(sqlite3* db, int nDb, const void *zKey, int nKey) { /* point the internal codec argument against the contet to be prepared */ rc = sqlcipher_codec_ctx_init(&ctx, pDb, pDb->pBt->pBt->pPager, fd, zKey, nKey); - if(rc != SQLITE_OK) return rc; /* initialization failed, do not attach potentially corrupted context */ + if(rc != SQLITE_OK) { + /* initialization failed, do not attach potentially corrupted context */ + sqlite3_mutex_leave(db->mutex); + return rc; + } sqlite3pager_sqlite3PagerSetCodec(sqlite3BtreePager(pDb->pBt), sqlite3Codec, NULL, sqlite3FreeCodecArg, (void *) ctx);