summaryrefslogtreecommitdiff
path: root/win32/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-24 15:39:52 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-24 15:39:52 +0000
commitb34321a2214cf2b46eec9b269847d4188421e7b6 (patch)
tree56b0ae5750da1a241f8084c88eb1a11d99ce0002 /win32/file.c
parent8ddc191df4d125285565b14e0bf319f0043ba63d (diff)
win32/file.c: fix result length
* win32/file.c (append_wstr): exclude the terminator from the result length when input len == -1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/file.c')
-rw-r--r--win32/file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/win32/file.c b/win32/file.c
index 6e7e5110ef5..8ed763d65e0 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -280,11 +280,12 @@ user_length_in_path(const wchar_t *wuser, size_t len)
}
static VALUE
-append_wstr(VALUE dst, const wchar_t *ws, size_t len, UINT cp, UINT path_cp, rb_encoding *path_encoding)
+append_wstr(VALUE dst, const WCHAR *ws, ssize_t len, UINT cp, UINT path_cp, rb_encoding *path_encoding)
{
long olen, nlen = (long)len;
if (cp == path_cp) {
+ if (len == -1) len = lstrlenW(ws);
nlen = WideCharToMultiByte(cp, 0, ws, len, NULL, 0, NULL, NULL);
olen = RSTRING_LEN(dst);
rb_str_modify_expand(dst, nlen);