Skip to content Skip to sidebar Skip to footer

Sqlite3_prepare_v2 Exc_bad_access In Ios 10

I have use sqlite in my iOS project for database. In iOS 9 all things are working perfectly. Now i have update new Xcode. But app is crashes many times at 'sqlite3_prepare_v2'. Als

Solution 1:

I think issue is in line 2592.

Do not treat key as string when passing it to sqlite3_key(...) Not sure how you generate key but if first byte is set '\0' then strlen return 0 (which may happen pretty often if you use some autogenerated helper based on NSData random bytes)

sqlite3_key definition:

SQLITE_API int SQLITE_STDCALL sqlite3_key(sqlite3 *db, constvoid *pKey, int nKey)

It expects nKey bytes where "\0" is allowed too

Instead try:

NSData *passBytes = [g_sqlite_key dataUsingEncoding:NSUTF8StringEncoding];
 int status = sqlite3_key(contactDB, passBytes.bytes, passBytes.length);
 if (status != SQLITE_OK) {
      // handle error and return
 }
 // continue...

Post a Comment for "Sqlite3_prepare_v2 Exc_bad_access In Ios 10"