Skip to content

Commit c62e106

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #77621: Already defined constants are not properly reported
2 parents fee9f3a + 8946ad3 commit c62e106

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

ext/com_dotnet/com_typeinfo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,17 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
195195
SysFreeString(bstr_ids);
196196

197197
/* sanity check for the case where the constant is already defined */
198+
php_com_zval_from_variant(&value, pVarDesc->lpvarValue, codepage);
198199
if ((exists = zend_get_constant(c.name)) != NULL) {
199-
if (COMG(autoreg_verbose) && !compare_function(&results, &c.value, exists)) {
200-
php_error_docref(NULL, E_WARNING, "Type library constant %s is already defined", c.name);
200+
if (COMG(autoreg_verbose) && !compare_function(&results, &value, exists)) {
201+
php_error_docref(NULL, E_WARNING, "Type library constant %s is already defined", ZSTR_VAL(c.name));
201202
}
202203
zend_string_release_ex(c.name, 1);
203204
ITypeInfo_ReleaseVarDesc(TypeInfo, pVarDesc);
204205
continue;
205206
}
206207

207208
/* register the constant */
208-
php_com_zval_from_variant(&value, pVarDesc->lpvarValue, codepage);
209209
if (Z_TYPE(value) == IS_LONG) {
210210
ZEND_CONSTANT_SET_FLAGS(&c, mode, 0);
211211
ZVAL_LONG(&c.value, Z_LVAL(value));

ext/com_dotnet/tests/bug77621.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #77621 (Already defined constants are not properly reported)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
?>
7+
--INI--
8+
com.autoregister_verbose=1
9+
--FILE--
10+
<?php
11+
define('ADSTYPE_INVALID', 0);
12+
$root = dirname(array_change_key_case($_SERVER, CASE_UPPER)['COMSPEC']);
13+
com_load_typelib("$root\activeds.tlb");
14+
?>
15+
===DONE===
16+
--EXPECTF--
17+
Warning: com_load_typelib(): Type library constant ADSTYPE_INVALID is already defined in %s on line %d
18+
===DONE===

0 commit comments

Comments
 (0)