diff options
Diffstat (limited to 'src/random.c')
-rw-r--r-- | src/random.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/random.c b/src/random.c index b82566524..179d01bef 100644 --- a/src/random.c +++ b/src/random.c @@ -48,11 +48,19 @@ void sqlite3_randomness(int N, void *pBuf){ #endif #if SQLITE_THREADSAFE - sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); - sqlite3_mutex_enter(mutex); + sqlite3_mutex *mutex; +#endif + +#ifndef SQLITE_OMIT_AUTOINIT + if( sqlite3_initialize() ) return; #endif - if( N<=0 ){ +#if SQLITE_THREADSAFE + mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); +#endif + + sqlite3_mutex_enter(mutex); + if( N<=0 || pBuf==0 ){ wsdPrng.isInit = 0; sqlite3_mutex_leave(mutex); return; |