diff options
author | suke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-25 21:57:46 +0000 |
---|---|---|
committer | suke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-25 21:57:46 +0000 |
commit | 71e6011d63fde90dc7f6dda1e93acfe0c6eae585 (patch) | |
tree | 7560624cde9a5a5c50d5d86be2ffbdf7d7826d35 | |
parent | 2ca7ad139f651baa6b8093f0f51fc0358e47b2c9 (diff) | |
download | ruby-71e6011d63fde90dc7f6dda1e93acfe0c6eae585.tar.gz |
* ext/win32ole/win32ole.c (ole_wc2mb, reg_enum_key): allocate
buffer should be NULL terminated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/win32ole/win32ole.c | 8 |
2 files changed, 10 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Sun Aug 26 06:51:46 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp> + + * ext/win32ole/win32ole.c (ole_wc2mb, reg_enum_key): allocate + buffer should be NULL terminated. + Sun Aug 26 06:04:13 2007 Koichi Sasada <ko1@atdot.net> * insnhelper.ci (vm_setup_method): reorder code for branch prediction. diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 8d76bc5fbb..28a6ec79f7 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -116,7 +116,7 @@ #define WC2VSTR(x) ole_wc2vstr((x), TRUE) -#define WIN32OLE_VERSION "1.0.4" +#define WIN32OLE_VERSION "1.0.5" typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); @@ -768,8 +768,9 @@ ole_wc2mb(LPWSTR pw) LPSTR pm; size = WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, NULL, 0, NULL, NULL); if (size) { - pm = ALLOC_N(char, size); + pm = ALLOC_N(char, size + 1); WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, pm, size, NULL, NULL); + pm[size] = '\0'; } else { pm = ALLOC_N(char, 1); @@ -1913,12 +1914,13 @@ reg_open_vkey(HKEY hkey, VALUE key, HKEY *phkey) static VALUE reg_enum_key(HKEY hkey, DWORD i) { - char buf[BUFSIZ]; + char buf[BUFSIZ + 1]; DWORD size_buf = sizeof(buf); FILETIME ft; LONG err = RegEnumKeyEx(hkey, i, buf, &size_buf, NULL, NULL, NULL, &ft); if(err == ERROR_SUCCESS) { + buf[BUFSIZ] = '\0'; return rb_str_new2(buf); } return Qnil; |