diff --git a/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp b/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp index 492be28a43ce..97de34821cc7 100644 --- a/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp +++ b/tracer/src/Datadog.Tracer.Native/cor_profiler.cpp @@ -684,22 +684,33 @@ HRESULT CorProfiler::TryRejitModule(ModuleID module_id) { if (module_info.assembly.name.rfind(skip_assembly_pattern, 0) == 0) { + bool is_included = false; // The assembly matches the "skip" prefix, but check if it's specifically included for (auto&& include_assembly : include_assemblies) { if (module_info.assembly.name == include_assembly) { - Logger::Debug("ModuleLoadFinished matched module by pattern: ", module_id, " ", module_info.assembly.name, - "but assembly is explicitly included"); - goto inject; + is_included = true; + break; } } - Logger::Debug("ModuleLoadFinished skipping module by pattern: ", module_id, " ", module_info.assembly.name); - return S_OK; + + if (is_included) + { + Logger::Debug("ModuleLoadFinished matched module by pattern: ", module_id, " ", + module_info.assembly.name, + "but assembly is explicitly included"); + break; + } + else + { + Logger::Debug("ModuleLoadFinished skipping module by pattern: ", module_id, " ", + module_info.assembly.name); + return S_OK; + } } } -inject: if (module_info.assembly.name == managed_profiler_name) { // Fix PInvoke Rewriting