|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-03-14 09:40 UTC] readjust at deneb dot freemail dot ne dot jp
conversion between CP932(a variant of Shift_JIS charset) and any Japanese charset other than CP932 unexpectantly failed when transliteration mode is specified like "EUC-JP//TRANSLIT" on the output encoding and the transliteration requires some larger buffer than strlen(input_buf) * sizeof(ucs4_t).
testing script:
<?php
for( $i = 0; $i < 20; ++$i ) {
print $i.":".iconv( "EUC-JP", "Shift_JIS", iconv( "CP932", "EUC-JP//TRANSLIT", "abcd".str_repeat( "****", $i ) ) )."<BR>";
}
for( $i = 0; $i < 20; ++$i ) {
print $i.":".iconv( "EUC-JP", "Shift_JIS", iconv( "CP932", "EUC-JP//TRANSLIT", "abcd".str_repeat( "++++", $i ) ) )."<BR>";
}
?>
where "****" is ONE character described as "SQUARE MIRIBAARU" (0x876D) and "++++" is ONE character described as "SQUARE AARU" (0x8765) on http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP932.TXT
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 23:00:01 2025 UTC |
I have just tried again with the HEAD. -------------------------------- $ ./buildconf $ ./configure --with-iconv=/usr/lib \ --prefix=/home/koizumi/local $ make $ make install $ /home/koizumi/local/bin/php -q test.php (13 lines printed) Segmentation fault -------------------------------- Backtrace: #0 0x401f2e8f in chunk_free (ar_ptr=0x402a6620, p=0x1c775d9f) at malloc.c:3225 #1 0x401f2bf4 in __libc_free (mem=0x81d1a48) at malloc.c:3154 #2 0x40035602 in libiconv_close () from /usr/lib/libiconv.so.2 #3 0x08062fe9 in php_iconv_string (in_p=0x81d17cc "", in_len=32, out=0xbfffd060, out_len=0xbfffd064, in_charset=0x81d66b4 "CP932", out_charset=0x81d0db4 "EUC-JP//TRANSLIT", err=0xbfffd068) at /home/koizumi/src/php4/ext/iconv/iconv.c:194 #4 0x0806308f in php_if_iconv (ht=3, return_value=0x81d0d24, this_ptr=0x0, return_value_used=1) at /home/koizumi/src/php4/ext/iconv/iconv.c:292 (gdb) select-frame 3 (gdb) print out_size $1 = 144 (gdb) print out_left $2 = 0 -------------------------------- Now I realized that what is to blame for segv. ------------------------------------------ *out_len = out_size - out_left; out_buffer[*out_len] = '\0'; icv_close(cd); ------------------------------------------ Here's the patch. (I'll resend this one if you think it better) =================================================================== RCS file: /repository/php4/ext/iconv/iconv.c,v retrieving revision 1.39 diff -u -r1.39 iconv.c --- iconv.c 28 Jun 2002 07:12:32 -0000 1.39 +++ iconv.c 5 Jul 2002 20:35:50 -0000 @@ -164,7 +164,7 @@ I added 15 extra bytes for safety. <yohgaki@php.net> */ out_size = in_len * sizeof(ucs4_t) + 16; - out_buffer = (char *) emalloc(out_size); + out_buffer = (char *) emalloc(out_size+1); *out = out_buffer; out_p = out_buffer; ============================================== THIS PATCH DOESN'T REALLY FIX THE BUG #16069.