diff options
author | drh <drh@noemail.net> | 2011-10-14 21:49:18 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2011-10-14 21:49:18 +0000 |
commit | b07028f71cd96b48a81474c6f1eea9596eb41cc7 (patch) | |
tree | 79e9ce2fc70ef9318d48c388431caf117fbdf001 /src/printf.c | |
parent | 0edb7acd3c2dcd913e5cecce8475aed8ff0850bf (diff) | |
download | sqlite-b07028f71cd96b48a81474c6f1eea9596eb41cc7.tar.gz sqlite-b07028f71cd96b48a81474c6f1eea9596eb41cc7.zip |
Add assert() statements and eliminate needless variable assignments in order
to get the clang scan-build utility to report zero problems against the
SQLite core. Clang's static analysis did find one real problem - but it was
in the command-line shell, not in the SQLite core.
FossilOrigin-Name: 60fee9574b0125705787e33c16f116cf188c8323
Diffstat (limited to 'src/printf.c')
-rw-r--r-- | src/printf.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/printf.c b/src/printf.c index 1303e17ed..0babee514 100644 --- a/src/printf.c +++ b/src/printf.c @@ -197,7 +197,6 @@ void sqlite3VXPrintf( #endif char buf[etBUFSIZE]; /* Conversion buffer */ - length = 0; bufpt = 0; for(; (c=(*fmt))!=0; ++fmt){ if( c!='%' ){ @@ -692,6 +691,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ testcase(p->mallocFailed); return; } + assert( p->zText!=0 || p->nChar==0 ); if( N<0 ){ N = sqlite3Strlen30(z); } @@ -723,7 +723,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ zNew = sqlite3_realloc(zOld, p->nAlloc); } if( zNew ){ - if( zOld==0 ) memcpy(zNew, p->zText, p->nChar); + if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar); p->zText = zNew; }else{ p->mallocFailed = 1; @@ -732,6 +732,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){ } } } + assert( p->zText ); memcpy(&p->zText[p->nChar], z, N); p->nChar += N; } |