diff options
author | drh <drh@noemail.net> | 2015-09-19 11:57:26 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-09-19 11:57:26 +0000 |
commit | 4977ccf1431327925e07a09f281efd6a494faa0d (patch) | |
tree | ffb975a950d0ca40d81cefe5c07ba6449afec7ca /ext/misc/json1.c | |
parent | 4cbc54b042d12b0684dc4fa2e0056e7422dd7a9a (diff) | |
download | sqlite-4977ccf1431327925e07a09f281efd6a494faa0d.tar.gz sqlite-4977ccf1431327925e07a09f281efd6a494faa0d.zip |
Fix an off-by-one error (really off-by-2 in this case) in the buffer
resize logic of json1.
FossilOrigin-Name: d2a027372a5a6efc0f9b6f605093d865ae1c6788
Diffstat (limited to 'ext/misc/json1.c')
-rw-r--r-- | ext/misc/json1.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/misc/json1.c b/ext/misc/json1.c index b878c0a3e..c59b09432 100644 --- a/ext/misc/json1.c +++ b/ext/misc/json1.c @@ -239,12 +239,13 @@ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ for(i=0; i<N; i++){ char c = zIn[i]; if( c=='"' || c=='\\' ){ - if( (p->nUsed+N+1-i > p->nAlloc) && jsonGrow(p,N+1-i)!=0 ) return; + if( (p->nUsed+N+3-i > p->nAlloc) && jsonGrow(p,N+3-i)!=0 ) return; p->zBuf[p->nUsed++] = '\\'; } p->zBuf[p->nUsed++] = c; } p->zBuf[p->nUsed++] = '"'; + assert( p->nUsed<p->nAlloc ); } /* |