Gabriel Ivăncescu : vbscript: Copy the variable names into the script dispatch's heap.

Alexandre Julliard julliard at winehq.org
Fri Dec 6 16:06:39 CST 2019


Module: wine
Branch: master
Commit: 99af868d7cd8cbbc8f83bccbc0537c22025c8db1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=99af868d7cd8cbbc8f83bccbc0537c22025c8db1

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Fri Dec  6 13:45:35 2019 +0100

vbscript: Copy the variable names into the script dispatch's heap.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/vbscript/vbscript.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c
index 94daace4fe..e068d19161 100644
--- a/dlls/vbscript/vbscript.c
+++ b/dlls/vbscript/vbscript.c
@@ -63,6 +63,14 @@ typedef struct {
     EXCEPINFO ei;
 } VBScriptError;
 
+static inline WCHAR *heap_pool_strdup(heap_pool_t *heap, const WCHAR *str)
+{
+    size_t size = (lstrlenW(str) + 1) * sizeof(WCHAR);
+    WCHAR *ret = heap_pool_alloc(heap, size);
+    if (ret) memcpy(ret, str, size);
+    return ret;
+}
+
 static void change_state(VBScript *This, SCRIPTSTATE state)
 {
     if(This->state == state)
@@ -120,7 +128,9 @@ static HRESULT exec_global_code(script_ctx_t *ctx, vbscode_t *code, VARIANT *res
         if (!(var = heap_pool_alloc(&obj->heap, sizeof(*var))))
             return E_OUTOFMEMORY;
 
-        var->name = code->main_code.vars[i].name;
+        var->name = heap_pool_strdup(&obj->heap, code->main_code.vars[i].name);
+        if (!var->name)
+            return E_OUTOFMEMORY;
         V_VT(&var->v) = VT_EMPTY;
         var->is_const = FALSE;
         var->array = NULL;




More information about the wine-cvs mailing list