From dc108feab8d88f62d7fcba3d2c9a058432463118 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 4 Aug 2020 18:25:50 +0200 Subject: [PATCH] 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. --- NEWS | 4 ++++ ext/com_dotnet/com_com.c | 6 ++---- ext/com_dotnet/com_extension.c | 4 +--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 782447d992..6b85632037 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,10 @@ PHP NEWS . Fixed bug #79934 (CRLF-only line in heredoc causes parsing error). (Pieter van den Ham) +- COM: + . Fixed bug #48585 (com_load_typelib holds reference, fails on second call). + (cmb) + - Gettext: . Fixed bug #70574 (Tests fail due to relying on Linux fallback behavior for gettext()). (Florian Engelhardt) diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 2eeac4aaf2..af72db63b1 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -248,7 +248,7 @@ PHP_FUNCTION(com_create_instance) TL = php_com_load_typelib_via_cache(typelib_name, obj->code_page, &cached); if (TL) { - if (COMG(autoreg_on) && !cached) { + if (COMG(autoreg_on)) { php_com_import_typelib(TL, mode, obj->code_page); } @@ -838,9 +838,7 @@ PHP_FUNCTION(com_load_typelib) php_com_initialize(); pTL = php_com_load_typelib_via_cache(name, codepage, &cached); if (pTL) { - if (cached) { - RETVAL_TRUE; - } else if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) { + if (php_com_import_typelib(pTL, cs ? CONST_CS : 0, codepage) == SUCCESS) { RETVAL_TRUE; } diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index 025f6803df..34e1f253e9 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -252,9 +252,7 @@ static PHP_INI_MH(OnTypeLibFileUpdate) } if ((pTL = php_com_load_typelib_via_cache(typelib_name, COMG(code_page), &cached)) != NULL) { - if (!cached) { - php_com_import_typelib(pTL, mode, COMG(code_page)); - } + php_com_import_typelib(pTL, mode, COMG(code_page)); ITypeLib_Release(pTL); } } -- 2.40.0