[PATCH v7 4/7] vbscript: Change release_dynamic_vars to release a single variable.

Gabriel Ivăncescu gabrielopcode at gmail.com
Mon Nov 11 06:34:25 CST 2019


We need to free them while iterating an array as well as a linked list.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/vbscript/interp.c   | 16 ++++++++--------
 dlls/vbscript/vbscript.c |  2 +-
 dlls/vbscript/vbscript.h |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c
index cf21601..d15a1b5 100644
--- a/dlls/vbscript/interp.c
+++ b/dlls/vbscript/interp.c
@@ -2243,22 +2243,22 @@ OP_LIST
 #undef X
 };
 
-void release_dynamic_vars(dynamic_var_t *var)
+void release_dynamic_var(dynamic_var_t *var)
 {
-    while(var) {
-        VariantClear(&var->v);
-        if(var->array)
-            SafeArrayDestroy(var->array);
-        var = var->next;
-    }
+    VariantClear(&var->v);
+    if(var->array)
+        SafeArrayDestroy(var->array);
 }
 
 static void release_exec(exec_ctx_t *ctx)
 {
+    dynamic_var_t *var;
     unsigned i;
 
     VariantClear(&ctx->ret_val);
-    release_dynamic_vars(ctx->dynamic_vars);
+
+    for(var = ctx->dynamic_vars; var; var = var->next)
+        release_dynamic_var(var);
 
     if(ctx->vbthis)
         IDispatchEx_Release(&ctx->vbthis->IDispatchEx_iface);
diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c
index 85107e7..fdade9f 100644
--- a/dlls/vbscript/vbscript.c
+++ b/dlls/vbscript/vbscript.c
@@ -217,7 +217,7 @@ static void release_script(script_ctx_t *ctx)
     clear_ei(&ctx->ei);
 
     for(i = 0; i < ctx->global_vars_cnt; i++)
-        VariantClear(&ctx->global_vars[i]->v);
+        release_dynamic_var(ctx->global_vars[i]);
 
     heap_free(ctx->global_vars);
     heap_free(ctx->global_funcs);
diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h
index a59f341..1cc36fd 100644
--- a/dlls/vbscript/vbscript.h
+++ b/dlls/vbscript/vbscript.h
@@ -361,7 +361,7 @@ void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
 HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD,vbscode_t**) DECLSPEC_HIDDEN;
 HRESULT compile_procedure(script_ctx_t*,const WCHAR*,const WCHAR*,DWORD,class_desc_t**) DECLSPEC_HIDDEN;
 HRESULT exec_script(script_ctx_t*,BOOL,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
-void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
+void release_dynamic_var(dynamic_var_t*) DECLSPEC_HIDDEN;
 IDispatch *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN;
 void clear_ei(EXCEPINFO*) DECLSPEC_HIDDEN;
 HRESULT report_script_error(script_ctx_t*) DECLSPEC_HIDDEN;
-- 
2.21.0




More information about the wine-devel mailing list