mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/win32ole/win32ole.c (ole_set_safe_array): should not use
recursive calling. * test/win32ole/test_win32ole_variant.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8d37cefaf8
commit
1b8aac3269
3 changed files with 29 additions and 15 deletions
|
@ -1,3 +1,10 @@
|
|||
Sat Jan 19 09:23:14 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_set_safe_array): should not use
|
||||
recursive calling.
|
||||
|
||||
* test/win32ole/test_win32ole_variant.rb: ditto.
|
||||
|
||||
Sat Jan 19 08:58:47 2008 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc/markup: Remove ListBase and Line constants.
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
|
||||
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
|
||||
|
||||
#define WIN32OLE_VERSION "1.1.2"
|
||||
#define WIN32OLE_VERSION "1.1.3"
|
||||
|
||||
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
|
||||
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
|
||||
|
@ -1074,29 +1074,28 @@ ole_set_safe_array(long n, SAFEARRAY *psa, long *pid, long *pub, VALUE val, long
|
|||
HRESULT hr = S_OK;
|
||||
VARIANT var;
|
||||
VOID *p = NULL;
|
||||
VariantInit(&var);
|
||||
if(n < 0) return;
|
||||
if(n == dim - 1) {
|
||||
long i = n;
|
||||
while(i >= 0) {
|
||||
val1 = ole_ary_m_entry(val, pid);
|
||||
VariantInit(&var);
|
||||
p = val2variant_ptr(val1, &var, vt);
|
||||
if (is_all_index_under(pid, pub, dim) == Qtrue) {
|
||||
if ((V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == NULL) ||
|
||||
(V_VT(&var) == VT_UNKNOWN && V_UNKNOWN(&var) == NULL)) {
|
||||
rb_raise(eWIN32OLERuntimeError, "argument does not have IDispatch or IUnknown Interface");
|
||||
if ((V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == NULL) ||
|
||||
(V_VT(&var) == VT_UNKNOWN && V_UNKNOWN(&var) == NULL)) {
|
||||
rb_raise(eWIN32OLERuntimeError, "element of array does not have IDispatch or IUnknown Interface");
|
||||
}
|
||||
hr = SafeArrayPutElement(psa, pid, p);
|
||||
}
|
||||
if (FAILED(hr)) {
|
||||
ole_raise(hr, rb_eRuntimeError, "failed to SafeArrayPutElement");
|
||||
}
|
||||
}
|
||||
pid[n] += 1;
|
||||
if (pid[n] <= pub[n]) {
|
||||
ole_set_safe_array(dim-1, psa, pid, pub, val, dim, vt);
|
||||
}
|
||||
else {
|
||||
pid[n] = 0;
|
||||
ole_set_safe_array(n-1, psa, pid, pub, val, dim, vt);
|
||||
pid[i] += 1;
|
||||
if (pid[i] > pub[i]) {
|
||||
pid[i] = 0;
|
||||
i -= 1;
|
||||
} else {
|
||||
i = dim - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -297,6 +297,13 @@ if defined?(WIN32OLE_VARIANT)
|
|||
assert_nil(obj.value)
|
||||
end
|
||||
|
||||
def test_s_new_array
|
||||
# should not occur stack over flow
|
||||
ar = (1..500000).to_a.map{|i| [i]}
|
||||
ar2 = WIN32OLE_VARIANT.new(ar)
|
||||
assert_equal(ar, ar2.value)
|
||||
end
|
||||
|
||||
def test_s_array
|
||||
obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_I4)
|
||||
assert_instance_of(WIN32OLE_VARIANT, obj)
|
||||
|
@ -326,6 +333,7 @@ if defined?(WIN32OLE_VARIANT)
|
|||
|
||||
obj = WIN32OLE_VARIANT.array([2,3], WIN32OLE::VARIANT::VT_DISPATCH)
|
||||
assert_equal([[nil, nil, nil],[nil,nil,nil]], obj.value)
|
||||
|
||||
end
|
||||
|
||||
def test_s_array_exc
|
||||
|
|
Loading…
Reference in a new issue