1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Make use of the flexible-array feature of C99, when available, to try to

pacify -fsanitize=strict-bounds.  This check-in fixes the core. There is
more yet to do in FTS3, RTREE, and in FTS5.

FossilOrigin-Name: 6fd6b32d06bd6a705e5140cd613af823b8183a6f6a9ceeeedfcf5e8b50821d68
This commit is contained in:
drh
2025-03-14 18:10:02 +00:00
parent dae87df198
commit cebf06c798
17 changed files with 175 additions and 108 deletions

View File

@@ -278,9 +278,9 @@ static VdbeCursor *allocateCursor(
i64 nByte;
VdbeCursor *pCx = 0;
nByte =
ROUND8P(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField +
(eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);
nByte = SZ_VDBECURSOR(nField);
assert( ROUND8(nByte)==nByte );
if( eCurType==CURTYPE_BTREE ) nByte += sqlite3BtreeCursorSize();
assert( iCur>=0 && iCur<p->nCursor );
if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
@@ -313,8 +313,8 @@ static VdbeCursor *allocateCursor(
pCx->nField = nField;
pCx->aOffset = &pCx->aType[nField];
if( eCurType==CURTYPE_BTREE ){
pCx->uc.pCursor = (BtCursor*)
&pMem->z[ROUND8P(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
assert( ROUND8(SZ_VDBECURSOR(nField))==SZ_VDBECURSOR(nField) );
pCx->uc.pCursor = (BtCursor*)&pMem->z[SZ_VDBECURSOR(nField)];
sqlite3BtreeCursorZero(pCx->uc.pCursor);
}
return pCx;
@@ -7705,7 +7705,7 @@ case OP_AggStep: {
**
** Note: We could avoid this by using a regular memory cell from aMem[] for
** the accumulator, instead of allocating one here. */
nAlloc = ROUND8P( sizeof(pCtx[0]) + (n-1)*sizeof(sqlite3_value*) );
nAlloc = ROUND8P( SZ_CONTEXT(n) );
pCtx = sqlite3DbMallocRawNN(db, nAlloc + sizeof(Mem));
if( pCtx==0 ) goto no_mem;
pCtx->pOut = (Mem*)((u8*)pCtx + nAlloc);