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

Fixes for failures in fuzz_malloc.test. (CVS 4334)

FossilOrigin-Name: d3e502263808c1fe0487fda02f16adcbb1279183
This commit is contained in:
danielk1977
2007-08-30 11:48:31 +00:00
parent eacb6c59bc
commit 7751940d6e
9 changed files with 36 additions and 36 deletions

View File

@@ -718,6 +718,7 @@ struct sgMprintf {
int nTotal; /* Output size if unconstrained */
int nAlloc; /* Amount of space allocated in zText */
void *(*xRealloc)(void*,int); /* Function used to realloc memory */
int iMallocFailed; /* True if xRealloc() has failed */
};
/*
@@ -728,6 +729,7 @@ struct sgMprintf {
*/
static void mout(void *arg, const char *zNewText, int nNewChar){
struct sgMprintf *pM = (struct sgMprintf*)arg;
if( pM->iMallocFailed ) return;
pM->nTotal += nNewChar;
if( pM->zText ){
if( pM->nChar + nNewChar + 1 > pM->nAlloc ){
@@ -738,6 +740,8 @@ static void mout(void *arg, const char *zNewText, int nNewChar){
if( pM->zText==pM->zBase ){
pM->zText = pM->xRealloc(0, nAlloc);
if( pM->zText==0 ){
pM->nAlloc = 0;
pM->iMallocFailed = 0;
return;
}else if( pM->nChar ){
memcpy(pM->zText, pM->zBase, pM->nChar);
@@ -748,8 +752,10 @@ static void mout(void *arg, const char *zNewText, int nNewChar){
if( zNew ){
pM->zText = zNew;
}else{
pM->iMallocFailed = 0;
pM->xRealloc(pM->zText, 0);
pM->zText = 0;
pM->nAlloc = 0;
return;
}
}
@@ -781,6 +787,7 @@ static char *base_vprintf(
sM.nChar = sM.nTotal = 0;
sM.nAlloc = nInitBuf;
sM.xRealloc = xRealloc;
sM.iMallocFailed = 0;
vxprintf(mout, &sM, useInternal, zFormat, ap);
if( xRealloc ){
if( sM.zText==sM.zBase ){