/ Check-in [1c220b80]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix two problems. Tests now passing.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | api-armor
Files: files | file ages | folders
SHA1:1c220b806d56e163842e17038c3331f71861bd9c
User & Date: drh 2014-10-24 12:37:00
Context
2014-10-27
18:34
Add the SQLITE_ENABLE_API_ARMOR compile-time option for extra API parameter validation. Enhance sqlite3_stricmp(), sqlite3_strnicmp(), and sqlite3_uri_parameter() for improved NULL parameter handling. check-in: ffb9d814 user: drh tags: trunk
2014-10-24
12:37
Fix two problems. Tests now passing. Closed-Leaf check-in: 1c220b80 user: drh tags: api-armor
00:35
Add the SQLITE_ENABLE_API_ARMOR compile-time option. This is a work in progress and is not yet completely functional. check-in: c297a84b user: drh tags: api-armor
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/malloc.c.

   471    471     return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p);
   472    472   }
   473    473   
   474    474   /*
   475    475   ** Free memory previously obtained from sqlite3Malloc().
   476    476   */
   477    477   void sqlite3_free(void *p){
   478         -#if defined(SQLITE_ENABLE_API_ARMOR) && !defined(SQLITE_OMIT_AUTOINIT)
   479         -  if( sqlite3_initialize() ) return;
   480         -#endif
   481    478     if( p==0 ) return;  /* IMP: R-49053-54554 */
   482    479     assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
   483    480     assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
   484    481     if( sqlite3GlobalConfig.bMemstat ){
   485    482       sqlite3_mutex_enter(mem0.mutex);
   486    483       sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p));
   487    484       sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);

Changes to src/random.c.

    33     33   void sqlite3_randomness(int N, void *pBuf){
    34     34     unsigned char t;
    35     35     unsigned char *zBuf = pBuf;
    36     36   
    37     37   #ifndef SQLITE_OMIT_AUTOINIT
    38     38     if( sqlite3_initialize() ) return;
    39     39   #endif
    40         -  if( pBuf==0 || N<=0 ) return;
    41     40   
    42     41     /* The "wsdPrng" macro will resolve to the pseudo-random number generator
    43     42     ** state vector.  If writable static data is unsupported on the target,
    44     43     ** we have to locate the state vector at run-time.  In the more common
    45     44     ** case where writable static data is supported, wsdPrng can refer directly
    46     45     ** to the "sqlite3Prng" state vector declared above.
    47     46     */
................................................................................
    52     51   # define wsdPrng sqlite3Prng
    53     52   #endif
    54     53   
    55     54   #if SQLITE_THREADSAFE
    56     55     sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);
    57     56     sqlite3_mutex_enter(mutex);
    58     57   #endif
           58  +
           59  +  if( N<=0 || pBuf==0 ){
           60  +    wsdPrng.isInit = 0;
           61  +    sqlite3_mutex_leave(mutex);
           62  +    return;
           63  +  }
    59     64   
    60     65     /* Initialize the state of the random number generator once,
    61     66     ** the first time this routine is called.  The seed value does
    62     67     ** not need to contain a lot of randomness since we are not
    63     68     ** trying to do secure encryption or anything like that...
    64     69     **
    65     70     ** Nothing in this file or anywhere else in SQLite does any kind of