summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-07 07:10:17 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-07 07:10:17 +0000
commitae6dd097f229e70b8d5693001b8ae50254559cc8 (patch)
tree8a86c9dc4aaa4c8dfdd2610315166972fb177695 /ext
parent27c7fd9acca91edb649d16cdd7822ac93f213c61 (diff)
* ext/win32ole/win32ole.c (ole_type_progid, reg_enum_key,
reg_get_val, ole_wc2mb): fix the bug. Thanks, arton. [ruby-dev:31576] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@13389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/win32ole/win32ole.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index dace9df..a2cac84 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -79,7 +79,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "0.7.1"
+#define WIN32OLE_VERSION "0.7.2"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -477,8 +477,9 @@ ole_wc2mb(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);
@@ -1138,12 +1139,13 @@ reg_enum_key(hkey, i)
HKEY hkey;
DWORD i;
{
- char buf[BUFSIZ];
- DWORD size_buf = sizeof(buf);
+ char buf[BUFSIZ + 1];
+ DWORD size_buf = sizeof(buf) - 1;
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;
@@ -1154,10 +1156,11 @@ reg_get_val(hkey, subkey)
HKEY hkey;
const char *subkey;
{
- char buf[BUFSIZ];
- LONG size_buf = sizeof(buf);
+ char buf[BUFSIZ + 1];
+ LONG size_buf = sizeof(buf) - 1;
LONG err = RegQueryValue(hkey, subkey, buf, &size_buf);
if (err == ERROR_SUCCESS) {
+ buf[BUFSIZ] = '\0';
return rb_str_new2(buf);
}
return Qnil;
@@ -3618,8 +3621,10 @@ ole_type_progid(pTypeInfo)
if (FAILED(hr))
return progid;
hr = ProgIDFromCLSID(&pTypeAttr->guid, &pbuf);
- if (SUCCEEDED(hr))
- progid = WC2VSTR(pbuf);
+ if (SUCCEEDED(hr)) {
+ progid = ole_wc2vstr(pbuf, FALSE);
+ CoTaskMemFree(pbuf);
+ }
OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
return progid;
}