From a49b8611b98c75a1b51c5f71e09b8a0e4f4646c7 Mon Sep 17 00:00:00 2001 From: drh Date: Sun, 16 Apr 2006 12:05:03 +0000 Subject: [PATCH] Allocate enough memory for the worst-case UTF-16 to UTF-8 conversion. Ticket #1773. (CVS 3174) FossilOrigin-Name: 2a0120c0f06d17185ede773729d97c93f90923ff --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/utf.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 42c0bc53b4..46033297e6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sconstant\sterms\sin\sthe\sORDER\sBY\sor\sGROUP\sBY\sclauses.\s\sTicket\s#1768.\s(CVS\s3173) -D 2006-04-11T14:16:21 +C Allocate\senough\smemory\sfor\sthe\sworst-case\sUTF-16\sto\sUTF-8\sconversion.\nTicket\s#1773.\s(CVS\s3174) +D 2006-04-16T12:05:03 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -86,7 +86,7 @@ F src/test_server.c a6460daed0b92ecbc2531b6dc73717470e7a648c F src/tokenize.c 91dc520980c0e2fb9265046adf8b7a86eff881dd F src/trigger.c 48bbb94c11954c8e132efcc04478efe8304c4196 F src/update.c 34add66fcd3301b33b6e4c4c813f4e408f7ee4a0 -F src/utf.c 1d51225bce1ea8d1978e8ab28e862a0c12c7a8e8 +F src/utf.c ab81ac59084ff1c07d421eb1a0a84ec809603b44 F src/util.c ca6ee72772c0f5dc04d2e0ab1973fd3b6a9bf79d F src/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9 F src/vdbe.c a56ef5de6d91aedf6f1f0db03c65aa01ecbe11ba @@ -355,7 +355,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 9d95750e8556aef20a637a815652d547ed2f887c -R 573c5535ced3d1d890b186177a1d009e +P d83e0230c0c4909cb035e266beffc0967526d9c1 +R 1e1e9e36a8b198dfc78ebe03fb97ac0f U drh -Z 807a1306c0c39a0be040f04b1cc803c5 +Z fad61796400585d36aa31de63a9d3216 diff --git a/manifest.uuid b/manifest.uuid index 64366077fd..3da0ea2288 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d83e0230c0c4909cb035e266beffc0967526d9c1 \ No newline at end of file +2a0120c0f06d17185ede773729d97c93f90923ff \ No newline at end of file diff --git a/src/utf.c b/src/utf.c index e15508e8f1..cd60b78f8d 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 -- 2.39.5