Index: third_party/sqlite/src/src/mutex_noop.c |
diff --git a/third_party/sqlite/src/src/mutex_noop.c b/third_party/sqlite/src/src/mutex_noop.c |
index 1a900c225adeea85188f6c9f87a411ac19ad9913..ecc84b4a94aeffca7782bc9331a7f2ded2915992 100644 |
--- a/third_party/sqlite/src/src/mutex_noop.c |
+++ b/third_party/sqlite/src/src/mutex_noop.c |
@@ -107,7 +107,7 @@ static int debugMutexEnd(void){ return SQLITE_OK; } |
** that means that a mutex could not be allocated. |
*/ |
static sqlite3_mutex *debugMutexAlloc(int id){ |
- static sqlite3_debug_mutex aStatic[SQLITE_MUTEX_STATIC_APP3 - 1]; |
+ static sqlite3_debug_mutex aStatic[SQLITE_MUTEX_STATIC_VFS3 - 1]; |
sqlite3_debug_mutex *pNew = 0; |
switch( id ){ |
case SQLITE_MUTEX_FAST: |
@@ -120,8 +120,12 @@ static sqlite3_mutex *debugMutexAlloc(int id){ |
break; |
} |
default: { |
- assert( id-2 >= 0 ); |
- assert( id-2 < (int)(sizeof(aStatic)/sizeof(aStatic[0])) ); |
+#ifdef SQLITE_ENABLE_API_ARMOR |
+ if( id-2<0 || id-2>=ArraySize(aStatic) ){ |
+ (void)SQLITE_MISUSE_BKPT; |
+ return 0; |
+ } |
+#endif |
pNew = &aStatic[id-2]; |
pNew->id = id; |
break; |
@@ -136,8 +140,13 @@ static sqlite3_mutex *debugMutexAlloc(int id){ |
static void debugMutexFree(sqlite3_mutex *pX){ |
sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX; |
assert( p->cnt==0 ); |
- assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ); |
- sqlite3_free(p); |
+ if( p->id==SQLITE_MUTEX_RECURSIVE || p->id==SQLITE_MUTEX_FAST ){ |
+ sqlite3_free(p); |
+ }else{ |
+#ifdef SQLITE_ENABLE_API_ARMOR |
+ (void)SQLITE_MISUSE_BKPT; |
+#endif |
+ } |
} |
/* |