1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-27 08:52:26 +03:00

Allocate enough memory for the worst-case UTF-16 to UTF-8 conversion.

Ticket #1773. (CVS 3174)

FossilOrigin-Name: 2a0120c0f06d17185ede773729d97c93f90923ff
This commit is contained in:
drh
2006-04-16 12:05:03 +00:00
parent 18e87cff0a
commit a49b8611b9
3 changed files with 11 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
C Allow\sconstant\sterms\sin\sthe\sORDER\sBY\sor\sGROUP\sBY\sclauses.\s\sTicket\s#1768.\s(CVS\s3173) C Allocate\senough\smemory\sfor\sthe\sworst-case\sUTF-16\sto\sUTF-8\sconversion.\nTicket\s#1773.\s(CVS\s3174)
D 2006-04-11T14:16:21 D 2006-04-16T12:05:03
F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -86,7 +86,7 @@ F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c
F src/tokenize.c 91dc520980c0e2fb9265046adf8b7a86eff881dd F src/tokenize.c 91dc520980c0e2fb9265046adf8b7a86eff881dd
F src/trigger.c 48bbb94c11954c8e132efcc04478efe8304c4196 F src/trigger.c 48bbb94c11954c8e132efcc04478efe8304c4196
F src/update.c 34add66fcd3301b33b6e4c4c813f4e408f7ee4a0 F src/update.c 34add66fcd3301b33b6e4c4c813f4e408f7ee4a0
F src/utf.c 1d51225bce1ea8d1978e8ab28e862a0c12c7a8e8 F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44
F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d
F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9 F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9
F src/vdbe.c a56ef5de6d91aedf6f1f0db03c65aa01ecbe11ba F src/vdbe.c a56ef5de6d91aedf6f1f0db03c65aa01ecbe11ba
@@ -355,7 +355,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 9d95750e8556aef20a637a815652d547ed2f887c P d83e0230c0c4909cb035e266beffc0967526d9c1
R 573c5535ced3d1d890b186177a1d009e R 1e1e9e36a8b198dfc78ebe03fb97ac0f
U drh U drh
Z 807a1306c0c39a0be040f04b1cc803c5 Z fad61796400585d36aa31de63a9d3216

View File

@@ -1 +1 @@
d83e0230c0c4909cb035e266beffc0967526d9c1 2a0120c0f06d17185ede773729d97c93f90923ff

View File

@@ -12,7 +12,7 @@
** This file contains routines used to translate between UTF-8, ** This file contains routines used to translate between UTF-8,
** UTF-16, UTF-16BE, and UTF-16LE. ** 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: ** 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. */ /* Set len to the maximum number of bytes required in the output buffer. */
if( desiredEnc==SQLITE_UTF8 ){ if( desiredEnc==SQLITE_UTF8 ){
/* When converting from UTF-16, the maximum growth results from /* When converting from UTF-16, the maximum growth results from
** translating a 2-byte character to a 3-byte UTF-8 character (i.e. ** translating a 2-byte character to a 4-byte UTF-8 character.
** code-point 0xFFFC). A single byte is required for the output string ** A single byte is required for the output string
** nul-terminator. ** nul-terminator.
*/ */
len = (pMem->n/2) * 3 + 1; len = pMem->n * 2 + 1;
}else{ }else{
/* When converting from UTF-8 to UTF-16 the maximum growth is caused /* 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 ** when a 1-byte UTF-8 character is translated into a 2-byte UTF-16