Skip to content

Commit 41bc51c

Browse files
committed
Fix #77578: Crash when php unload
Since we're putting `ITypeLib *`s into the hash, we're getting `ITypeLib *`s back, not `ITypeLib **`s.
1 parent f21c054 commit 41bc51c

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ PHP NEWS
1515
. Fixed bug #77742 (bcpow() implementation related to gcc compiler
1616
optimization). (Nikita)
1717

18+
- COM:
19+
. Fixed bug #77578 (Crash when php unload). (cmb)
20+
1821
- Date:
1922
. Fixed bug #50020 (DateInterval:createDateFromString() silently fails).
2023
(Derick)

ext/com_dotnet/com_typeinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
225225
/* Type-library stuff */
226226
void php_com_typelibrary_dtor(zval *pDest)
227227
{
228-
ITypeLib **Lib = (ITypeLib**)Z_PTR_P(pDest);
229-
ITypeLib_Release(*Lib);
228+
ITypeLib *Lib = (ITypeLib*)Z_PTR_P(pDest);
229+
ITypeLib_Release(Lib);
230230
}
231231

232232
PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib_via_cache(char *search_string,

ext/com_dotnet/tests/bug77578.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #77578 (Crash when php unload)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('com_dotnet')) die('skip com_dotnet extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
// To actually be able to verify the crash during shutdown on Windows, we have
10+
// to execute a PHP subprocess, and check its exit status.
11+
$php = PHP_BINARY;
12+
$ini = php_ini_loaded_file();
13+
$iniopt = $ini ? "-c $ini" : '';
14+
$command = "$php $iniopt -d com.autoregister_typelib=1 -r \"new COM('WbemScripting.SWbemLocator');\"";
15+
exec($command, $output, $status);
16+
var_dump($output, $status);
17+
?>
18+
===DONE===
19+
--EXPECT--
20+
array(0) {
21+
}
22+
int(0)
23+
===DONE===

0 commit comments

Comments
 (0)