From 2404f4a367d658dc2b54f89381e6038a1bb68660 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 22 Jan 2016 11:52:22 +0800
Subject: widl: Avoid relying on side effects when marking function index as
 the last one.

---
 tools/widl/write_sltg.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/widl/write_sltg.c b/tools/widl/write_sltg.c
index bf2ba5f..acfc039 100644
--- a/tools/widl/write_sltg.c
+++ b/tools/widl/write_sltg.c
@@ -1465,11 +1465,12 @@ static void add_interface_typeinfo(struct sltg_typelib *typelib, type_t *iface)
 
     STATEMENTS_FOR_EACH_FUNC(stmt_func, type_iface_get_stmts(iface))
     {
-        if (i == func_count - 1) i |= 0x80000000;
+        int idx = inherited_func_count + i;
+
+        if (i == func_count - 1) idx |= 0x80000000;
 
         base_offset += add_func_desc(typelib, &data, stmt_func->u.var,
-                                     inherited_func_count + i,
-                                     dispid++, base_offset, &hrefmap);
+                                     idx, dispid + i, base_offset, &hrefmap);
         i++;
     }
 
-- 
2.6.4

