ruby-changes:3632
From: ko1@a...
Date: Sat, 19 Jan 2008 09:29:50 +0900 (JST)
Subject: [ruby-changes:3632] suke - Ruby:r15121 (trunk): * ext/win32ole/win32ole.c (ole_set_safe_array): should not use
suke 2008-01-19 09:29:31 +0900 (Sat, 19 Jan 2008)
New Revision: 15121
Modified files:
trunk/ChangeLog
trunk/ext/win32ole/win32ole.c
trunk/test/win32ole/test_win32ole_variant.rb
Log:
* ext/win32ole/win32ole.c (ole_set_safe_array): should not use
recursive calling.
* test/win32ole/test_win32ole_variant.rb: ditto.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/win32ole/test_win32ole_variant.rb?r1=15121&r2=15120&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15121&r2=15120&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/win32ole/win32ole.c?r1=15121&r2=15120&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15120)
+++ ChangeLog (revision 15121)
@@ -1,3 +1,10 @@
+Sat Jan 19 09:23:14 2008 Masaki Suketa <masaki.suketa@n...>
+
+ * 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@s...>
* lib/rdoc/markup: Remove ListBase and Line constants.
Index: ext/win32ole/win32ole.c
===================================================================
--- ext/win32ole/win32ole.c (revision 15120)
+++ ext/win32ole/win32ole.c (revision 15121)
@@ -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,30 +1074,29 @@
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[i] += 1;
+ if (pid[i] > pub[i]) {
+ pid[i] = 0;
+ i -= 1;
+ } else {
+ i = dim - 1;
+ }
}
- 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);
- }
}
static long
Index: test/win32ole/test_win32ole_variant.rb
===================================================================
--- test/win32ole/test_win32ole_variant.rb (revision 15120)
+++ test/win32ole/test_win32ole_variant.rb (revision 15121)
@@ -297,6 +297,13 @@
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 @@
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
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/