summaryrefslogtreecommitdiff
path: root/ext/com_dotnet/com_olechar.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-04-29 13:40:44 +0200
committerAnatol Belski <ab@php.net>2014-04-29 13:40:44 +0200
commit2d625b5f81205d7f0217243b0bfe9a77683951e8 (patch)
tree54f142ba56098a1ae70bca121fe5c7120f21a9ec /ext/com_dotnet/com_olechar.c
parentbb422cb60e69794b3ea9d7d47fcc8a976a385608 (diff)
downloadphp-git-2d625b5f81205d7f0217243b0bfe9a77683951e8.tar.gz
Fixed bug #66431 Special Character via COM Interface (CP_UTF8)
Diffstat (limited to 'ext/com_dotnet/com_olechar.c')
-rw-r--r--ext/com_dotnet/com_olechar.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ext/com_dotnet/com_olechar.c b/ext/com_dotnet/com_olechar.c
index a3e81978bd..bf42b4fffb 100644
--- a/ext/com_dotnet/com_olechar.c
+++ b/ext/com_dotnet/com_olechar.c
@@ -46,7 +46,13 @@ PHP_COM_DOTNET_API OLECHAR *php_com_string_to_olestring(char *string, uint strin
if (string_len > 0) {
olestring = (OLECHAR*)safe_emalloc(string_len, sizeof(OLECHAR), 0);
+ /* XXX if that's a real multibyte string, olestring is obviously allocated excessively.
+ This should be fixed by reallocating the olestring, but as emalloc is used, that doesn't
+ matter much. */
ok = MultiByteToWideChar(codepage, flags, string, string_len, olestring, string_len);
+ if (ok > 0 && ok < string_len) {
+ olestring[ok] = '\0';
+ }
} else {
ok = FALSE;
olestring = (OLECHAR*)emalloc(sizeof(OLECHAR));