Skip to content

Commit f9ba2ca

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #62474: com_event_sink crashes on certain arguments
2 parents ac2e958 + 7424bfc commit f9ba2ca

File tree

3 files changed

+41
-20
lines changed

3 files changed

+41
-20
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ PHP NEWS
88
. Fixed bug #80258 (Windows Deduplication Enabled, randon permission errors).
99
(cmb)
1010

11+
- COM:
12+
. Fixed bug #62474 (com_event_sink crashes on certain arguments). (cmb)
13+
1114
- IMAP:
1215
. Fixed bug #64076 (imap_sort() does not return FALSE on failure). (cmb)
1316
. Fixed bug #76618 (segfault on imap_reopen). (girgias)

ext/com_dotnet/com_typeinfo.c

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,20 @@ ITypeInfo *php_com_locate_typeinfo(char *typelibname, php_com_dotnet_object *obj
311311

312312
if (obj) {
313313
if (dispname == NULL && sink) {
314-
IProvideClassInfo2 *pci2;
315-
IProvideClassInfo *pci;
314+
if (V_VT(&obj->v) == VT_DISPATCH) {
315+
IProvideClassInfo2 *pci2;
316+
IProvideClassInfo *pci;
316317

317-
if (SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IProvideClassInfo2, (void**)&pci2))) {
318-
gotguid = SUCCEEDED(IProvideClassInfo2_GetGUID(pci2, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid));
319-
IProvideClassInfo2_Release(pci2);
320-
}
321-
if (!gotguid && SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IProvideClassInfo, (void**)&pci))) {
322-
/* examine the available interfaces */
323-
/* TODO: write some code here */
324-
php_error_docref(NULL, E_WARNING, "IProvideClassInfo: this code not yet written!");
325-
IProvideClassInfo_Release(pci);
318+
if (SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IProvideClassInfo2, (void**)&pci2))) {
319+
gotguid = SUCCEEDED(IProvideClassInfo2_GetGUID(pci2, GUIDKIND_DEFAULT_SOURCE_DISP_IID, &iid));
320+
IProvideClassInfo2_Release(pci2);
321+
}
322+
if (!gotguid && SUCCEEDED(IDispatch_QueryInterface(V_DISPATCH(&obj->v), &IID_IProvideClassInfo, (void**)&pci))) {
323+
/* examine the available interfaces */
324+
/* TODO: write some code here */
325+
php_error_docref(NULL, E_WARNING, "IProvideClassInfo: this code not yet written!");
326+
IProvideClassInfo_Release(pci);
327+
}
326328
}
327329
} else if (dispname == NULL) {
328330
if (obj->typeinfo) {
@@ -339,15 +341,17 @@ ITypeInfo *php_com_locate_typeinfo(char *typelibname, php_com_dotnet_object *obj
339341
/* get the library from the object; the rest will be dealt with later */
340342
ITypeInfo_GetContainingTypeLib(obj->typeinfo, &typelib, &idx);
341343
} else if (typelibname == NULL) {
342-
IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &typeinfo);
343-
if (dispname) {
344-
unsigned int idx;
345-
/* get the library from the object; the rest will be dealt with later */
346-
ITypeInfo_GetContainingTypeLib(typeinfo, &typelib, &idx);
347-
348-
if (typelib) {
349-
ITypeInfo_Release(typeinfo);
350-
typeinfo = NULL;
344+
if (V_VT(&obj->v) == VT_DISPATCH) {
345+
IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &typeinfo);
346+
if (dispname) {
347+
unsigned int idx;
348+
/* get the library from the object; the rest will be dealt with later */
349+
ITypeInfo_GetContainingTypeLib(typeinfo, &typelib, &idx);
350+
351+
if (typelib) {
352+
ITypeInfo_Release(typeinfo);
353+
typeinfo = NULL;
354+
}
351355
}
352356
}
353357
}

ext/com_dotnet/tests/bug62474.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #62474 (com_event_sink crashes on certain arguments)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
var_dump(com_event_sink(new variant, function() {}, array()));
10+
var_dump(com_event_sink(new variant, new variant, 'a'));
11+
?>
12+
--EXPECT--
13+
bool(false)
14+
bool(false)

0 commit comments

Comments
 (0)