Avoid pointer aliasing in the allocSpace() routine in vdbeaux.c.
FossilOrigin-Name: d6ae27512229d95502c584b17bb2cbdba401f80a
This commit is contained in:
parent
1e15c031ca
commit
4800b2ee95
18
manifest
18
manifest
@ -1,8 +1,8 @@
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA1
|
||||
|
||||
C Begin\supdating\sAPI\sdocumentation\sto\suse\sthe\snew\sMD5-hash\sbased\s\nautomatic\srequirements\snumbering.\s\sComment\schanges\sonly.\s\sMany\ssimilar\nchanges\swill\sfollow.
|
||||
D 2009-12-08T15:16:54
|
||||
C Avoid\spointer\saliasing\sin\sthe\sallocSpace()\sroutine\sin\svdbeaux.c.
|
||||
D 2009-12-08T15:35:23
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -216,7 +216,7 @@ F src/vdbe.c 5ed06318aac5d57849170a8bf39e807c22c5fedd
|
||||
F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2
|
||||
F src/vdbeInt.h d7ea821ac7813c9bea0fe87558c35e07b2c7c44d
|
||||
F src/vdbeapi.c bb128b819b9ef1a2ce211a36a6cb70a1643fa239
|
||||
F src/vdbeaux.c 6b9da05a16fbb52afd2bf0b3080087afdf16b6eb
|
||||
F src/vdbeaux.c 86d43cdf9615235e1def993a945dfaabc20ab079
|
||||
F src/vdbeblob.c 84f924700a7a889152aeebef77ca5f4e3875ffb4
|
||||
F src/vdbemem.c 1e16e3a16e55f4c3452834f0e041726021aa66e0
|
||||
F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
|
||||
@ -780,14 +780,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P 7b1cfd65a6f7c85ef8f6e4622973457cff9d007c
|
||||
R bc9b0ca13c1d42e3ef0f31c3eafc2706
|
||||
P 973c5c86eed31dcce54d14e71938f2e255f5f1c7
|
||||
R c570a97b0ffcfd39f4ed66f9f0662c03
|
||||
U drh
|
||||
Z d3399929cb27f5d1d2ae1fd2280572aa
|
||||
Z ee7e56c2d879987294a2e31ad1fde920
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.6 (GNU/Linux)
|
||||
|
||||
iD8DBQFLHm3toxKgR168RlERAqh0AJ42+WxiDaf+yXW7XeNGamk5NI4QnQCcD5Ck
|
||||
Um9oKXZSMb+HswKtI2ZkMrA=
|
||||
=dxuM
|
||||
iD8DBQFLHnI+oxKgR168RlERAn/LAJ9meRPYFG8kZK/fIyNChkghTUHQWgCdGqla
|
||||
K42FnTiSLRLIME8ykgShkdk=
|
||||
=3fbN
|
||||
-----END PGP SIGNATURE-----
|
||||
|
@ -1 +1 @@
|
||||
973c5c86eed31dcce54d14e71938f2e255f5f1c7
|
||||
d6ae27512229d95502c584b17bb2cbdba401f80a
|
@ -1254,11 +1254,15 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){
|
||||
#endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */
|
||||
|
||||
/*
|
||||
** Allocate space from a fixed size buffer. Make *pp point to the
|
||||
** allocated space. (Note: pp is a char* rather than a void** to
|
||||
** work around the pointer aliasing rules of C.) *pp should initially
|
||||
** be zero. If *pp is not zero, that means that the space has already
|
||||
** been allocated and this routine is a noop.
|
||||
** Allocate space from a fixed size buffer and return a pointer to
|
||||
** that space. If insufficient space is available, return NULL.
|
||||
**
|
||||
** The pBuf parameter is the initial value of a pointer which will
|
||||
** receive the new memory. pBuf is normally NULL. If pBuf is not
|
||||
** NULL, it means that memory space has already been allocated and that
|
||||
** this routine should not allocate any new memory. When pBuf is not
|
||||
** NULL simply return pBuf. Only allocate new memory space when pBuf
|
||||
** is NULL.
|
||||
**
|
||||
** nByte is the number of bytes of space needed.
|
||||
**
|
||||
@ -1269,23 +1273,23 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){
|
||||
** to allocate. If there is insufficient space in *ppFrom to satisfy the
|
||||
** request, then increment *pnByte by the amount of the request.
|
||||
*/
|
||||
static void allocSpace(
|
||||
char *pp, /* IN/OUT: Set *pp to point to allocated buffer */
|
||||
static void *allocSpace(
|
||||
void *pBuf, /* Where return pointer will be stored */
|
||||
int nByte, /* Number of bytes to allocate */
|
||||
u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */
|
||||
u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */
|
||||
int *pnByte /* If allocation cannot be made, increment *pnByte */
|
||||
){
|
||||
assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
|
||||
if( (*(void**)pp)==0 ){
|
||||
nByte = ROUND8(nByte);
|
||||
if( &(*ppFrom)[nByte] <= pEnd ){
|
||||
*(void**)pp = (void *)*ppFrom;
|
||||
*ppFrom += nByte;
|
||||
}else{
|
||||
*pnByte += nByte;
|
||||
}
|
||||
if( pBuf ) return pBuf;
|
||||
nByte = ROUND8(nByte);
|
||||
if( &(*ppFrom)[nByte] <= pEnd ){
|
||||
pBuf = (void*)*ppFrom;
|
||||
*ppFrom += nByte;
|
||||
}else{
|
||||
*pnByte += nByte;
|
||||
}
|
||||
return pBuf;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1358,13 +1362,12 @@ void sqlite3VdbeMakeReady(
|
||||
|
||||
do {
|
||||
nByte = 0;
|
||||
allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
|
||||
allocSpace((char*)&p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
|
||||
allocSpace((char*)&p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
|
||||
allocSpace((char*)&p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
|
||||
allocSpace((char*)&p->apCsr,
|
||||
nCursor*sizeof(VdbeCursor*), &zCsr, zEnd, &nByte
|
||||
);
|
||||
p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
|
||||
p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
|
||||
p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
|
||||
p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
|
||||
p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*),
|
||||
&zCsr, zEnd, &nByte);
|
||||
if( nByte ){
|
||||
p->pFree = sqlite3DbMallocZero(db, nByte);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user