Jacek Caban : mshtml: Remove duplicated property entries in preprocess_dispex_data.

Alexandre Julliard julliard at winehq.org
Wed Jan 16 13:47:43 CST 2013


Module: wine
Branch: master
Commit: bce6ee2b84629e2ce51f45ea2309ca29bf29bb97
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bce6ee2b84629e2ce51f45ea2309ca29bf29bb97

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Jan 16 12:36:08 2013 +0100

mshtml: Remove duplicated property entries in preprocess_dispex_data.

---

 dlls/mshtml/dispex.c          |   16 ++++++++++++++++
 dlls/mshtml/tests/jstest.html |   13 +++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c
index 793bbb9..ed799d2 100644
--- a/dlls/mshtml/dispex.c
+++ b/dlls/mshtml/dispex.c
@@ -373,6 +373,22 @@ static dispex_data_t *preprocess_dispex_data(DispatchEx *This)
     data->funcs = heap_realloc(data->funcs, data->func_cnt * sizeof(func_info_t));
     qsort(data->funcs, data->func_cnt, sizeof(func_info_t), dispid_cmp);
 
+    for(i = 1; i < data->func_cnt && data->funcs[i-1].id != data->funcs[i].id; i++);
+    if(i < data->func_cnt) {
+        unsigned j = i--;
+
+        /* We have at least one duplicated property. This may happen if more than one
+         * interface implements the same property. We have to remove these duplicated
+         * entries. */
+
+        while(j < data->func_cnt) {
+            while(j+1 < data->func_cnt && data->funcs[j+1].id == data->funcs[j].id)
+                j++;
+            data->funcs[i++] = data->funcs[j++];
+        }
+        data->func_cnt = i;
+    }
+
     data->name_table = heap_alloc(data->func_cnt * sizeof(func_info_t*));
     for(i=0; i < data->func_cnt; i++)
         data->name_table[i] = data->funcs+i;
diff --git a/dlls/mshtml/tests/jstest.html b/dlls/mshtml/tests/jstest.html
index 2bd87b1..ebf2861 100644
--- a/dlls/mshtml/tests/jstest.html
+++ b/dlls/mshtml/tests/jstest.html
@@ -165,6 +165,18 @@ function test_override_functions() {
     ok(tmp === "test", "div.addBehavior() = " + tmp);
 }
 
+function test_forin() {
+    var cnt=0;
+
+    document.body.innerHTML = '<a id="aid"></a>';
+
+    for(var x in document.getElementById("aid")) {
+        cnt++;
+    }
+
+    ok(cnt > 100, "cnt = " + cnt);
+}
+
 var globalVar = false;
 
 function runTests() {
@@ -185,6 +197,7 @@ function runTests() {
     test_attribute_collection();
     test_arg_conv();
     test_override_functions();
+    test_forin();
 
     var r = window.execScript("globalVar = true;");
     ok(r === undefined, "execScript returned " + r);




More information about the wine-cvs mailing list