Skip to content

Commit dc108fe

Browse files
committed
Fix #48585: com_load_typelib holds reference, fails on second call
Whether the type library is cached is actually irrelevant here; what matters is that the symbols are imported, and since these are not cached, we have to import them for every request. And we cannot cache the symbols, because the import depends on the current codepage, but the codepage is a `PHP_INI_ALL` setting.
1 parent 9d9dffe commit dc108fe

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ PHP NEWS
1212
. Fixed bug #79934 (CRLF-only line in heredoc causes parsing error).
1313
(Pieter van den Ham)
1414

15+
- COM:
16+
. Fixed bug #48585 (com_load_typelib holds reference, fails on second call).
17+
(cmb)
18+
1519
- Gettext:
1620
. Fixed bug #70574 (Tests fail due to relying on Linux fallback behavior for
1721
gettext()). (Florian Engelhardt)

ext/com_dotnet/com_com.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ PHP_FUNCTION(com_create_instance)
248248
TL = php_com_load_typelib_via_cache(typelib_name, obj->code_page, &cached);
249249

250250
if (TL) {
251-
if (COMG(autoreg_on) && !cached) {
251+
if (COMG(autoreg_on)) {
252252
php_com_import_typelib(TL, mode, obj->code_page);
253253
}
254254

@@ -838,9 +838,7 @@ PHP_FUNCTION(com_load_typelib)
838838
php_com_initialize();
839839
pTL = php_com_load_typelib_via_cache(name, codepage, &cached);
840840
if (pTL) {
841-
if (cached) {
842-
RETVAL_TRUE;
843-
} else if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) {
841+
if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) {
844842
RETVAL_TRUE;
845843
}
846844

ext/com_dotnet/com_extension.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ static PHP_INI_MH(OnTypeLibFileUpdate)
252252
}
253253

254254
if ((pTL = php_com_load_typelib_via_cache(typelib_name, COMG(code_page), &cached)) != NULL) {
255-
if (!cached) {
256-
php_com_import_typelib(pTL, mode, COMG(code_page));
257-
}
255+
php_com_import_typelib(pTL, mode, COMG(code_page));
258256
ITypeLib_Release(pTL);
259257
}
260258
}

0 commit comments

Comments
 (0)