mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
IN32OLE_VARIANT.new accepts nil as first argument for some VARIANT TYPE. fix memory leak.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dbee678630
commit
72cc74655f
4 changed files with 45 additions and 21 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Fri Jan 19 06:53:38 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (olevariant_free): fix memory leak.
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata):
|
||||
WIN32OLE_VARIANT.new accepts nil as first argument for some VARIANT
|
||||
TYPE.
|
||||
|
||||
* test/win32ole/test_win32ole: ditto.
|
||||
|
||||
Wed Jan 17 17:31:28 2007 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* some refactoring around yarvcore and proc.
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
|
||||
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
|
||||
|
||||
#define WIN32OLE_VERSION "0.8.3"
|
||||
#define WIN32OLE_VERSION "0.8.4"
|
||||
|
||||
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
|
||||
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
|
||||
|
@ -1148,27 +1148,35 @@ ole_val2olevariantdata(VALUE val, VARTYPE vtype, struct olevariantdata *pvar)
|
|||
SafeArrayDestroy(psa);
|
||||
}
|
||||
} else {
|
||||
ole_val2variant(val, &(pvar->realvar));
|
||||
if (vtype & VT_BYREF) {
|
||||
if ( (vtype & ~VT_BYREF) == V_VT(&(pvar->realvar))) {
|
||||
if (val == Qnil) {
|
||||
V_VT(&(pvar->realvar)) = vtype & ~VT_BYREF;
|
||||
V_VT(&(pvar->var)) = vtype;
|
||||
if (vtype & VT_BYREF) {
|
||||
ole_var2ptr_var(&(pvar->realvar), &(pvar->var));
|
||||
} else {
|
||||
VariantInit(&var);
|
||||
hr = VariantChangeTypeEx(&(var), &(pvar->realvar),
|
||||
LOCALE_SYSTEM_DEFAULT, 0, (VARTYPE)(vtype & ~VT_BYREF));
|
||||
if (SUCCEEDED(hr)) {
|
||||
VariantClear(&(pvar->realvar));
|
||||
hr = VariantCopy(&(pvar->realvar), &var);
|
||||
VariantClear(&var);
|
||||
ole_var2ptr_var(&(pvar->realvar), &(pvar->var));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (vtype == V_VT(&(pvar->realvar))) {
|
||||
hr = VariantCopy(&(pvar->var), &(pvar->realvar));
|
||||
ole_val2variant(val, &(pvar->realvar));
|
||||
if (vtype & VT_BYREF) {
|
||||
if ( (vtype & ~VT_BYREF) == V_VT(&(pvar->realvar))) {
|
||||
ole_var2ptr_var(&(pvar->realvar), &(pvar->var));
|
||||
} else {
|
||||
VariantInit(&var);
|
||||
hr = VariantChangeTypeEx(&(var), &(pvar->realvar),
|
||||
LOCALE_SYSTEM_DEFAULT, 0, (VARTYPE)(vtype & ~VT_BYREF));
|
||||
if (SUCCEEDED(hr)) {
|
||||
VariantClear(&(pvar->realvar));
|
||||
hr = VariantCopy(&(pvar->realvar), &var);
|
||||
VariantClear(&var);
|
||||
ole_var2ptr_var(&(pvar->realvar), &(pvar->var));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hr = VariantChangeTypeEx(&(pvar->var), &(pvar->realvar),
|
||||
LOCALE_SYSTEM_DEFAULT, 0, vtype);
|
||||
if (vtype == V_VT(&(pvar->realvar))) {
|
||||
hr = VariantCopy(&(pvar->var), &(pvar->realvar));
|
||||
} else {
|
||||
hr = VariantChangeTypeEx(&(pvar->var), &(pvar->realvar),
|
||||
LOCALE_SYSTEM_DEFAULT, 0, vtype);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6810,6 +6818,7 @@ olevariant_free(struct olevariantdata *pvar)
|
|||
{
|
||||
VariantClear(&(pvar->realvar));
|
||||
VariantClear(&(pvar->var));
|
||||
free(pvar);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
|
@ -105,5 +105,10 @@ if defined?(WIN32OLE_VARIANT)
|
|||
assert_equal([65, 0], obj.value)
|
||||
end
|
||||
|
||||
def test_create_nil_dispatch
|
||||
var = WIN32OLE_VARIANT.new(nil, WIN32OLE::VARIANT::VT_DISPATCH)
|
||||
assert_nil(var.value)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2007-01-17"
|
||||
#define RUBY_RELEASE_DATE "2007-01-19"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20070117
|
||||
#define RUBY_RELEASE_CODE 20070119
|
||||
#define RUBY_PATCHLEVEL 0
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
|
@ -9,7 +9,7 @@
|
|||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2007
|
||||
#define RUBY_RELEASE_MONTH 1
|
||||
#define RUBY_RELEASE_DAY 17
|
||||
#define RUBY_RELEASE_DAY 19
|
||||
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
RUBY_EXTERN const char ruby_release_date[];
|
||||
|
|
Loading…
Reference in a new issue