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);