Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug #41577 fix: reinitialization of dotnet_domain structure member #681

Merged
merged 1 commit into from

2 participants

@akasparas

Please consider this bugfix for longstanding bug.

@php-pulls php-pulls merged commit d339ddf into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 3 deletions.
  1. +30 −3 ext/com_dotnet/com_dotnet.c
View
33 ext/com_dotnet/com_dotnet.c
@@ -198,7 +198,8 @@ PHP_FUNCTION(com_dotnet_create_instance)
IUnknown *unk = NULL;
php_com_initialize(TSRMLS_C);
- if (COMG(dotnet_runtime_stuff) == NULL) {
+ stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
+ if (stuff == NULL) {
hr = dotnet_init(&where TSRMLS_CC);
if (FAILED(hr)) {
char buf[1024];
@@ -210,9 +211,35 @@ PHP_FUNCTION(com_dotnet_create_instance)
ZVAL_NULL(object);
return;
}
- }
+ stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
- stuff = (struct dotnet_runtime_stuff*)COMG(dotnet_runtime_stuff);
+ } else if (stuff->dotnet_domain == NULL) {
+ where = "ICorRuntimeHost_GetDefaultDomain";
+ hr = ICorRuntimeHost_GetDefaultDomain(stuff->dotnet_host, &unk);
+ if (FAILED(hr)) {
+ char buf[1024];
+ char *err = php_win32_error_to_msg(hr);
+ snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
+ if (err)
+ LocalFree(err);
+ php_com_throw_exception(hr, buf TSRMLS_CC);
+ ZVAL_NULL(object);
+ return;
+ }
+
+ where = "QI: System._AppDomain";
+ hr = IUnknown_QueryInterface(unk, &IID_mscorlib_System_AppDomain, (LPVOID*)&stuff->dotnet_domain);
+ if (FAILED(hr)) {
+ char buf[1024];
+ char *err = php_win32_error_to_msg(hr);
+ snprintf(buf, sizeof(buf), "Failed to re-init .Net domain [%s] %s", where, err);
+ if (err)
+ LocalFree(err);
+ php_com_throw_exception(hr, buf TSRMLS_CC);
+ ZVAL_NULL(object);
+ return;
+ }
+ }
obj = CDNO_FETCH(object);
Something went wrong with that request. Please try again.