Index: third_party/sqlite/src/src/random.c |
diff --git a/third_party/sqlite/src/src/random.c b/third_party/sqlite/src/src/random.c |
index b82566524c40c6bb87154a259d7c24077d54e394..179d01bef247d46245804d4bce88e427feedcfe5 100644 |
--- a/third_party/sqlite/src/src/random.c |
+++ b/third_party/sqlite/src/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; |