From 1b7ee6db884b7574893bc737a6f7fb5fdf9d619b Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 26 Aug 2020 15:31:26 +0200 Subject: [PATCH] Fix com_safearray_proxy related memory management issues --- ext/com_dotnet/com_saproxy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index bde19869921..fa6ee347622 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -114,6 +114,8 @@ static zval *saproxy_read_dimension(zval *object, zval *offset, int type, zval * Z_STRLEN(proxy->indices[0]), DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, proxy->dimensions, args, 0); + efree(args); + if (res == SUCCESS) { php_com_zval_from_variant(rv, &v, proxy->obj->code_page); VariantClear(&v); @@ -387,7 +389,7 @@ static zend_object* saproxy_clone(zval *object) memcpy(cloneproxy, proxy, sizeof(*cloneproxy)); Z_ADDREF_P(cloneproxy->zobj); - cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval *), 0); + cloneproxy->indices = safe_emalloc(cloneproxy->dimensions, sizeof(zval), 0); clone_indices(cloneproxy, proxy, proxy->dimensions); return &cloneproxy->std; @@ -437,7 +439,7 @@ int php_com_saproxy_create(zval *com_object, zval *proxy_out, zval *index) } Z_ADDREF_P(proxy->zobj); - proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval *), 0); + proxy->indices = safe_emalloc(proxy->dimensions, sizeof(zval), 0); if (rel) { clone_indices(proxy, rel, rel->dimensions);