Skip to content

Commit 767fa3d

Browse files
committed
Fix #77626: Persistence confusion in php_com_import_typelib()
We apply only the most minimal fix here, and will cater to the unnecessary re-allocation for PHP-7.4. We don't need to add a regression test, since bug39606.phpt and bug77621.phpt already show the misbehavior.
1 parent 8946ad3 commit 767fa3d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PHP NEWS
1717
- COM:
1818
. Fixed bug #77621 (Already defined constants are not properly reported).
1919
(cmb)
20+
. Fixed bug #77626 (Persistence confusion in php_com_import_typelib()). (cmb)
2021

2122
- Mbstring:
2223
. Fixed bug #77514 (mb_ereg_replace() with trailing backslash adds null byte).

ext/com_dotnet/com_typeinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
184184
}
185185

186186
const_name = php_com_olestring_to_string(bstr_ids, &len, codepage);
187-
c.name = zend_string_init(const_name, len, 1);
187+
c.name = zend_string_init(const_name, len, mode & CONST_PERSISTENT);
188188
// TODO: avoid reallocation???
189189
efree(const_name);
190190
if(c.name == NULL) {
@@ -200,7 +200,7 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
200200
if (COMG(autoreg_verbose) && !compare_function(&results, &value, exists)) {
201201
php_error_docref(NULL, E_WARNING, "Type library constant %s is already defined", ZSTR_VAL(c.name));
202202
}
203-
zend_string_release_ex(c.name, 1);
203+
zend_string_release_ex(c.name, mode & CONST_PERSISTENT);
204204
ITypeInfo_ReleaseVarDesc(TypeInfo, pVarDesc);
205205
continue;
206206
}

0 commit comments

Comments
 (0)