1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-19 21:43:15 +03:00

Harden the STAT4 logic in where.c against OOM faults.

FossilOrigin-Name: 91d2cfbc95c34c0040deb69106bb9f895abb94c0
This commit is contained in:
drh
2013-09-03 19:26:22 +00:00
parent b13af4c5dd
commit fbc38de980
3 changed files with 12 additions and 9 deletions

View File

@@ -2421,12 +2421,15 @@ static void whereKeyStats(
tRowcnt *aStat /* OUT: stats written here */
){
IndexSample *aSample = pIdx->aSample;
int iCol = pRec->nField-1; /* Index of required stats in anEq[] etc. */
int iCol; /* Index of required stats in anEq[] etc. */
int iMin = 0; /* Smallest sample not yet tested */
int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
int iTest; /* Next sample to test */
int res; /* Result of comparison operation */
assert( pRec!=0 || pParse->db->mallocFailed );
if( pRec==0 ) return;
iCol = pRec->nField - 1;
assert( pIdx->nSample>0 );
assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
do{