ID: 37899 Updated by: [EMAIL PROTECTED] Reported By: okumurya at hotmail dot com Status: Assigned Bug Type: COM related Operating System: Windows 2000 Professional PHP Version: 4.4.2 Assigned To: wez New Comment:
Could you provide some example reproducing the problem? Preferably with some COM available on standard Windows/Office machine or easily installable. Previous Comments: ------------------------------------------------------------------------ [2007-03-05 22:43:52] okumurya at hotmail dot com Hello fjortiz > did your last patch work for you? Yes my patch works. ------------------------------------------------------------------------ [2007-02-26 13:03:29] fjortiz at comunet dot es Any updates on this issue?. We tracked down one problem we had with ADODBCommand COM objects and Russian UTF-8 strings and found this was the bug that was causing it. Mr. Okumurya, please one question: did your last patch work for you? Thanks in advance. ------------------------------------------------------------------------ [2006-07-03 07:31:00] okumurya at hotmail dot com I misunderstand. Revised patch is following. --- ext\com\conversion.c.orig 2006-01-01 22:46:50.000000000 +0900 +++ ext\com\conversion.c 2006-06-23 14:01:42.838476800 +0900 @@ -247,8 +247,9 @@ case VT_BSTR: convert_to_string_ex(&pval_arg); + unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC); - V_BSTR(var_arg) = SysAllocStringByteLen((char *) unicode_str, Z_STRLEN_P(pval_arg) * sizeof(OLECHAR)); + V_BSTR(var_arg) = SysAllocString(unicode_str); efree(unicode_str); break; @@ -787,20 +788,15 @@ { BOOL error = FALSE; OLECHAR *unicode_str; + uint unicode_strlen; - if (strlen == -1) { - /* request needed buffersize */ - strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, -1, NULL, 0); - } else { - /* \0 terminator */ - strlen++; - } + unicode_strlen = MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, -1, NULL, 0); - if (strlen >= 0) { - unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * strlen); + if (unicode_strlen > 0) { + unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR) * unicode_strlen); /* convert string */ - error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, strlen, unicode_str, strlen); + error = !MultiByteToWideChar(codepage, (codepage == CP_UTF8 ? 0 : MB_PRECOMPOSED | MB_ERR_INVALID_CHARS), C_str, -1, unicode_str, unicode_strlen); } else { /* return a zero-length string */ unicode_str = (OLECHAR *) emalloc(sizeof(OLECHAR)); ------------------------------------------------------------------------ [2006-06-23 05:09:36] okumurya at hotmail dot com Description: ------------ In UTF-8, 'Z_STRLEN_P(pval_arg) * sizeof(OLECHAR)' is longer than Widechar. So SysAllocStringByteLen copies junk datas. following is a patch. --- conversion.c.orig 2006-06-23 11:28:06.496027200 +0900 +++ conversion.c 2006-06-23 14:01:42.838476800 +0900 @@ -247,8 +247,9 @@ case VT_BSTR: convert_to_string_ex(&pval_arg); + unicode_str = php_char_to_OLECHAR(Z_STRVAL_P(pval_arg), Z_STRLEN_P(pval_arg), codepage TSRMLS_CC); - V_BSTR(var_arg) = SysAllocStringByteLen((char *) unicode_str, Z_STRLEN_P(pval_arg) * sizeof(OLECHAR)); + V_BSTR(var_arg) = SysAllocString(unicode_str); efree(unicode_str); break; ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37899&edit=1