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

Fixes for platforms with 32-bit pointers that require 64-bit values to be aligned.

FossilOrigin-Name: 2212d7488ed4ec2839ffa45cb9567056b36519434834634e4ecc441c330694d7
This commit is contained in:
dan
2024-07-13 16:53:56 +00:00
parent 0b9efaffd7
commit 7acf972c59
7 changed files with 48 additions and 25 deletions

View File

@@ -7671,18 +7671,28 @@ case OP_AggInverse:
case OP_AggStep: {
int n;
sqlite3_context *pCtx;
u64 nAlloc;
assert( pOp->p4type==P4_FUNCDEF );
n = pOp->p5;
assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
assert( n==0 || (pOp->p2>0 && pOp->p2+n<=(p->nMem+1 - p->nCursor)+1) );
assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+n );
pCtx = sqlite3DbMallocRawNN(db, n*sizeof(sqlite3_value*) +
(sizeof(pCtx[0]) + sizeof(Mem) - sizeof(sqlite3_value*)));
/* Allocate space for (a) the context object and (n-1) extra pointers
** to append to the sqlite3_context.argv[1] array, and (b) a memory
** cell in which to store the accumulation. Be careful that the memory
** cell is 8-byte aligned, even on platforms where a pointer is 32-bits.
**
** 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*) );
pCtx = sqlite3DbMallocRawNN(db, nAlloc + sizeof(Mem));
if( pCtx==0 ) goto no_mem;
pCtx->pMem = 0;
pCtx->pOut = (Mem*)&(pCtx->argv[n]);
pCtx->pOut = (Mem*)((u8*)pCtx + nAlloc);
sqlite3VdbeMemInit(pCtx->pOut, db, MEM_Null);
pCtx->pMem = 0;
pCtx->pFunc = pOp->p4.pFunc;
pCtx->iOp = (int)(pOp - aOp);
pCtx->pVdbe = p;