-C Fix\sanother\suninitialized\sMem.xDel\sproblem.\s(CVS\s1672)
-D 2004-06-22T22:54:23
+C Add\sa\scomment\sto\sthe\soutput\sbuffer\sallocation\sin\ssqlite3VdbeMemTranslate()\s(CVS\s1673)
+D 2004-06-23T00:23:49
F Makefile.in 0a3d7aaefa50717bd550b0cf568a51072c4c103c
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F src/tokenize.c 900374b6b37f04748bcd48c2d29a41c251542935
F src/trigger.c 296e888ae931e9774e1761996b2b66db40f7d216
F src/update.c b66b1896c9da54678ba3eff2bf0b4d291a95986a
-F src/utf.c c5ae076b5b9e1a4fac72a48f0005508ab4118d1b
+F src/utf.c 9c66605c5eac4c4aa999207634fabe7885e5b0b3
F src/util.c e31e35d3d76cab7a02045095064897eca49cbce3
F src/vacuum.c fcb930215a3f6c50087300782555f61ad11dd80c
F src/vdbe.c 0d8f2fea386c173997fb8eab555ab999497591fe
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P e17ea666b1eb1df12a1d4d78bda2e025e2aa30bd
-R 4e9bb61466aecc430c6837fcb2b3e202
-U drh
-Z 76bcb96ce9daaf4663984472a800f8fe
+P cb4e242e83ba111c5da1f9662fda5a890051e7b0
+R bd4ff00f259823f00b7fc8204e6c5fa3
+U danielk1977
+Z ed06ef82d5f64ca5dbd5ac31ceda856c
-cb4e242e83ba111c5da1f9662fda5a890051e7b0
\ No newline at end of file
+e2f7f182987fbfe8611ead8bd1f12b2e8b47f6dc
\ No newline at end of file
** This file contains routines used to translate between UTF-8,
** UTF-16, UTF-16BE, and UTF-16LE.
**
-** $Id: utf.c,v 1.23 2004/06/22 22:04:46 drh Exp $
+** $Id: utf.c,v 1.24 2004/06/23 00:23:49 danielk1977 Exp $
**
** Notes on UTF-8:
**
goto translate_out;
}
+ /* Set len to the maximum number of bytes required in the output buffer. */
+ if( desiredEnc==SQLITE_UTF8 ){
+ /* When converting from UTF-16, the maximum growth results from
+ ** translating a 2-byte character to a 3-byte UTF-8 character (i.e.
+ ** code-point 0xFFFC). A single byte is required for the output string
+ ** nul-terminator.
+ */
+ len = (pMem->n/2) * 3 + 1;
+ }else{
+ /* When converting from UTF-8 to UTF-16 the maximum growth is caused
+ ** when a 1-byte UTF-8 character is translated into a 2-byte UTF-16
+ ** character. Two bytes are required in the output buffer for the
+ ** nul-terminator.
+ */
+ len = pMem->n * 2 + 2;
+ }
+
/* Set zIn to point at the start of the input buffer and zTerm to point 1
** byte past the end.
**
*/
zIn = pMem->z;
zTerm = &zIn[pMem->n];
- len = pMem->n*2 + 2;
if( len>NBFS ){
zOut = sqliteMallocRaw(len);
if( !zOut ) return SQLITE_NOMEM;
WRITE_UTF8(z, 0);
pMem->n = (z-zOut)-1;
}
- assert( pMem->n+1<=len );
}
+ assert( (pMem->n+(desiredEnc==SQLITE_UTF8?1:2))<=len );
sqlite3VdbeMemRelease(pMem);
pMem->flags &= ~(MEM_Static|MEM_Dyn|MEM_Ephem|MEM_Short);