Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/jscript.c | 12 ++++++++++-- dlls/jscript/jscript.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index 5e02d4f..5e9b153 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -143,6 +143,14 @@ named_item_t *lookup_named_item(script_ctx_t *ctx, const WCHAR *item_name, unsig return NULL; }
+void release_named_item(named_item_t *item) +{ + if(--item->ref) return; + + heap_free(item->name); + heap_free(item); +} + static inline JScriptError *impl_from_IActiveScriptError(IActiveScriptError *iface) { return CONTAINING_RECORD(iface, JScriptError, IActiveScriptError_iface); @@ -415,8 +423,7 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
if(iter->disp) IDispatch_Release(iter->disp); - heap_free(iter->name); - heap_free(iter); + release_named_item(iter); iter = iter2; }
@@ -833,6 +840,7 @@ static HRESULT WINAPI JScript_AddNamedItem(IActiveScript *iface, return E_OUTOFMEMORY; }
+ item->ref = 1; item->disp = disp; item->flags = dwFlags; item->name = heap_strdupW(pstrName); diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 8297838..efd5a54 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -206,6 +206,7 @@ HRESULT builtin_set_const(script_ctx_t*,jsdisp_t*,jsval_t) DECLSPEC_HIDDEN;
typedef struct named_item_t { IDispatch *disp; + unsigned ref; DWORD flags; LPWSTR name;
@@ -213,6 +214,7 @@ typedef struct named_item_t { } named_item_t;
named_item_t *lookup_named_item(script_ctx_t*,const WCHAR*,unsigned) DECLSPEC_HIDDEN; +void release_named_item(named_item_t*) DECLSPEC_HIDDEN;
typedef struct { const WCHAR *name;