Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions ext/com_dotnet/com_typeinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ PHP_COM_DOTNET_API zend_result php_com_import_typelib(ITypeLib *TL, int mode, in
VARDESC *pVarDesc;
UINT NameCount;
BSTR bstr_ids;
zend_constant c;
zval *exists, results, value;

if (TL == NULL) {
Expand Down Expand Up @@ -224,16 +223,13 @@ PHP_COM_DOTNET_API zend_result php_com_import_typelib(ITypeLib *TL, int mode, in

/* register the constant */
if (Z_TYPE(value) == IS_LONG) {
ZEND_CONSTANT_SET_FLAGS(&c, mode, 0);
ZVAL_LONG(&c.value, Z_LVAL(value));
if (mode & CONST_PERSISTENT) {
/* duplicate string in a persistent manner */
c.name = zend_string_dup(const_name, /* persistent */ true);
zend_string_release_ex(const_name, /* persistent */ false);
} else {
c.name = const_name;
}
zend_register_constant(&c);
zend_register_long_constant(
ZSTR_VAL(const_name),
ZSTR_LEN(const_name),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like const_name will leak. It previously moved ownership, or was released. I don't know if this code path is tested in CI.

Z_LVAL(value),
mode,
0
);
}
ITypeInfo_ReleaseVarDesc(TypeInfo, pVarDesc);
}
Expand Down
Loading