mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Improved overrun detection in mem2.c (SQLITE_MEMDEBUG). Previously was only checking up to 3 extra bytes allocated due to rounding. (CVS 6261)
FossilOrigin-Name: a6fe3d6b02734b23fe067a373c0232024a782a6c
This commit is contained in:
11
src/mem2.c
11
src/mem2.c
@@ -19,7 +19,7 @@
|
||||
** This file contains implementations of the low-level memory allocation
|
||||
** routines specified in the sqlite3_mem_methods object.
|
||||
**
|
||||
** $Id: mem2.c,v 1.42 2008/12/10 19:26:24 drh Exp $
|
||||
** $Id: mem2.c,v 1.43 2009/02/05 03:00:06 shane Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -163,9 +163,11 @@ static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){
|
||||
pInt = (int*)pAllocation;
|
||||
pU8 = (u8*)pAllocation;
|
||||
assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );
|
||||
assert( (nReserve-0)<=p->iSize || pU8[nReserve-1]==0x65 );
|
||||
assert( (nReserve-1)<=p->iSize || pU8[nReserve-2]==0x65 );
|
||||
assert( (nReserve-2)<=p->iSize || pU8[nReserve-3]==0x65 );
|
||||
/* This checks any of the "extra" bytes allocated due
|
||||
** to rounding up to an 8 byte boundary to ensure
|
||||
** they haven't been overwritten.
|
||||
*/
|
||||
while( nReserve-- > p->iSize ) assert( pU8[nReserve]==0x65 );
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -186,6 +188,7 @@ static int sqlite3MemSize(void *p){
|
||||
*/
|
||||
static int sqlite3MemInit(void *NotUsed){
|
||||
UNUSED_PARAMETER(NotUsed);
|
||||
assert( (sizeof(struct MemBlockHdr)&7) == 0 );
|
||||
if( !sqlite3GlobalConfig.bMemstat ){
|
||||
/* If memory status is enabled, then the malloc.c wrapper will already
|
||||
** hold the STATIC_MEM mutex when the routines here are invoked. */
|
||||
|
||||
Reference in New Issue
Block a user