Index: ext/misc/json1.c ================================================================== --- ext/misc/json1.c +++ ext/misc/json1.c @@ -1846,11 +1846,13 @@ int i; int inStr = 0; char *z; JsonString *pStr; pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); - if( !pStr ) return; + /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will + ** always have been called to initalize it */ + if( NEVER(!pStr) ) return; z = pStr->zBuf; for(i=1; z[i]!=',' || inStr; i++){ assert( inUsed ); if( z[i]=='"' ){ inStr = !inStr; Index: src/func.c ================================================================== --- src/func.c +++ src/func.c @@ -1519,11 +1519,13 @@ int type; assert( argc==1 ); UNUSED_PARAMETER(argc); p = sqlite3_aggregate_context(context, sizeof(*p)); type = sqlite3_value_numeric_type(argv[0]); - if( p && type!=SQLITE_NULL ){ + /* p is always non-NULL because sumStep() will have been called first + ** to initialize it */ + if( ALWAYS(p) && type!=SQLITE_NULL ){ p->cnt--; if( type==SQLITE_INTEGER ){ i64 v = sqlite3_value_int64(argv[0]); p->rSum -= v; if( (p->approx|p->overflow)==0 && sqlite3AddInt64(&p->iSum, -1*v) ){ @@ -1603,11 +1605,12 @@ } #ifndef SQLITE_OMIT_WINDOWFUNC static void countInverse(sqlite3_context *ctx, int argc, sqlite3_value **argv){ CountCtx *p; p = sqlite3_aggregate_context(ctx, sizeof(*p)); - if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && p ){ + /* p is always non-NULL since countStep() will have been called first */ + if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0])) && ALWAYS(p) ){ p->n--; #ifdef SQLITE_DEBUG p->bInverse = 1; #endif } @@ -1722,11 +1725,13 @@ int n; assert( argc==1 || argc==2 ); StrAccum *pAccum; if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum)); - if( pAccum ){ + /* pAccum is always non-NULL since groupConcatStep() will have always + ** run frist to initialize it */ + if( ALWAYS(pAccum) ){ n = sqlite3_value_bytes(argv[0]); if( argc==2 ){ n += sqlite3_value_bytes(argv[1]); }else{ n++;