aboutsummaryrefslogtreecommitdiff
path: root/src/utf.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2006-04-16 12:05:03 +0000
committerdrh <drh@noemail.net>2006-04-16 12:05:03 +0000
commita49b8611b98c75a1b51c5f71e09b8a0e4f4646c7 (patch)
treec62a0093e34e99daa9b9821f2512dbe1341d90c3 /src/utf.c
parent18e87cff0a1c3f92552081b28376bf6cc59aae8c (diff)
downloadsqlite-a49b8611b98c75a1b51c5f71e09b8a0e4f4646c7.tar.gz
sqlite-a49b8611b98c75a1b51c5f71e09b8a0e4f4646c7.zip
Allocate enough memory for the worst-case UTF-16 to UTF-8 conversion.
Ticket #1773. (CVS 3174) FossilOrigin-Name: 2a0120c0f06d17185ede773729d97c93f90923ff
Diffstat (limited to 'src/utf.c')
-rw-r--r--src/utf.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/utf.c b/src/utf.c
index e15508e8f..cd60b78f8 100644
--- a/src/utf.c
+++ b/src/utf.c
@@ -12,7 +12,7 @@
** This file contains routines used to translate between UTF-8,
** UTF-16, UTF-16BE, and UTF-16LE.
**
-** $Id: utf.c,v 1.38 2006/02/24 02:53:50 drh Exp $
+** $Id: utf.c,v 1.39 2006/04/16 12:05:03 drh Exp $
**
** Notes on UTF-8:
**
@@ -287,11 +287,11 @@ int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){
/* 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
+ ** translating a 2-byte character to a 4-byte UTF-8 character.
+ ** A single byte is required for the output string
** nul-terminator.
*/
- len = (pMem->n/2) * 3 + 1;
+ len = pMem->n * 2 + 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