com php-src: Fix #77621: Already defined constants are not properly reported: NEWS ext/com_dotnet/com_typeinfo.c ext/com_ dotnet/tests/bug77621.phpt
| From: | Christoph Michael Becker | Date: | Thu, 14 Feb 2019 23:35:21 +0000 |
| Subject: | com php-src: Fix #77621: Already defined constants are not properly reported: NEWS ext/com_dotnet/com_typeinfo.c ext/com_ dotnet/tests/bug77621.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104650@lists.php.net to get a copy of this message | ||
Commit: de738496c2c323b580d9aff0f121876e4101a910
Author: Christoph M. Becker <cmbecker69@gmx.de> Fri, 15 Feb 2019 00:35:21 +0100
Parents: 0ffa84d7401d61a251029c0813e38a69f84a9486
Branches: PHP-7.2 PHP-7..3 PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=de738496c2c323b580d9aff0f121876e4101a910
Log:
Fix #77621: Already defined constants are not properly reported
We must not check uninitialized values (i.e.
c.value), and we have to
use proper types for printf-style formats (i.e. char * instead of
zend_string *).
Bugs:
https://bugs.php.net/77621
Changed paths:
M NEWS
M ext/com_dotnet/com_typeinfo.c
A ext/com_dotnet/tests/bug77621.phpt
Diff:
diff --git a/NEWS b/NEWS
index a4dd406..2f6d4ef 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed bug #77589 (Core dump using parse_ini_string with numeric sections).
(Laruence)
+- COM:
+ . Fixed bug #77621 (Already defined constants are not properly reported).
+ (cmb)
+
- PDO_OCI:
. Support Oracle Database tracing attributes ACTION, MODULE,
CLIENT_INFO, and CLIENT_IDENTIFIER. (Cameron Porter)
diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c
index a0fa3c0..40f21ae 100644
--- a/ext/com_dotnet/com_typeinfo.c
+++ b/ext/com_dotnet/com_typeinfo.c
@@ -197,9 +197,10 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int
codepa
SysFreeString(bstr_ids);
/* sanity check for the case where the constant is already defined */
+ php_com_zval_from_variant(&value, pVarDesc->lpvarValue, codepage);
if ((exists = zend_get_constant(c.name)) != NULL) {
- if (COMG(autoreg_verbose) && !compare_function(&results, &c.value, exists)) {
- php_error_docref(NULL, E_WARNING, "Type library constant %s is already defined",
c.name);
+ if (COMG(autoreg_verbose) && !compare_function(&results, &value, exists)) {
+ php_error_docref(NULL, E_WARNING, "Type library constant %s is already defined",
ZSTR_VAL(c.name));
}
zend_string_release(c.name);
ITypeInfo_ReleaseVarDesc(TypeInfo, pVarDesc);
@@ -207,7 +208,6 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
}
/* register the constant */
- php_com_zval_from_variant(&value, pVarDesc->lpvarValue, codepage);
if (Z_TYPE(value) == IS_LONG) {
c.flags = mode;
ZVAL_LONG(&c.value, Z_LVAL(value));
diff --git a/ext/com_dotnet/tests/bug77621.phpt b/ext/com_dotnet/tests/bug77621.phpt
new file mode 100644
index 0000000..5c24494
--- /dev/null
+++ b/ext/com_dotnet/tests/bug77621.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #77621 (Already defined constants are not properly reported)
+--SKIPIF--
+<?php
+if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not
available');
+?>
+--INI--
+com.autoregister_verbose=1
+--FILE--
+<?php
+define('ADSTYPE_INVALID', 0);
+$root = dirname(array_change_key_case($_SERVER, CASE_UPPER)['COMSPEC']);
+com_load_typelib("$root\activeds.tlb");
+?>
+===DONE===
+--EXPECTF--
+Warning: com_load_typelib(): Type library constant ADSTYPE_INVALID is already defined in %s on line
%d
+===DONE===