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

Fix a problem handling a malloc() failure in printf.c. Also some other things to improve test coverage. (CVS 4361)

FossilOrigin-Name: 595bfe72f053bc6ecb58bb9044a4cdc53d30b404
This commit is contained in:
danielk1977
2007-09-01 09:02:53 +00:00
parent 95c8a54c7d
commit ca0c89715e
10 changed files with 259 additions and 175 deletions

View File

@@ -741,7 +741,7 @@ static void mout(void *arg, const char *zNewText, int nNewChar){
pM->zText = pM->xRealloc(0, nAlloc);
if( pM->zText==0 ){
pM->nAlloc = 0;
pM->iMallocFailed = 0;
pM->iMallocFailed = 1;
return;
}else if( pM->nChar ){
memcpy(pM->zText, pM->zBase, pM->nChar);
@@ -752,7 +752,7 @@ static void mout(void *arg, const char *zNewText, int nNewChar){
if( zNew ){
pM->zText = zNew;
}else{
pM->iMallocFailed = 0;
pM->iMallocFailed = 1;
pM->xRealloc(pM->zText, 0);
pM->zText = 0;
pM->nAlloc = 0;
@@ -789,7 +789,8 @@ static char *base_vprintf(
sM.xRealloc = xRealloc;
sM.iMallocFailed = 0;
vxprintf(mout, &sM, useInternal, zFormat, ap);
if( xRealloc ){
assert(sM.iMallocFailed==0 || sM.zText==0);
if( xRealloc && !sM.iMallocFailed ){
if( sM.zText==sM.zBase ){
sM.zText = xRealloc(0, sM.nChar+1);
if( sM.zText ){