From 1b96e8bbc48c8c893b5be637711f664f353d5449 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 15 Oct 2024 14:40:33 -0700 Subject: [PATCH] Implement fix in DNMD for https://github.com/dotnet/runtime/pull/108907 --- src/interfaces/importhelpers.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/interfaces/importhelpers.cpp b/src/interfaces/importhelpers.cpp index 3dbb33e6..cd65ac9b 100644 --- a/src/interfaces/importhelpers.cpp +++ b/src/interfaces/importhelpers.cpp @@ -602,17 +602,20 @@ namespace uint32_t publicKeyLength; if (1 != md_get_column_value_as_blob(sourceAssembly, mdtAssembly_PublicKey, 1, &publicKey, &publicKeyLength)) return E_FAIL; - + + span publicKeyTokenSpan; StrongNameToken publicKeyToken; if (publicKey != nullptr) { assert(IsAfPublicKey(flags)); flags &= ~afPublicKey; RETURN_IF_FAILED(StrongNameTokenFromPublicKey({ publicKey, publicKeyLength }, publicKeyToken)); + publicKeyTokenSpan = { publicKeyToken.data(), publicKeyToken.size() }; } else { assert(!IsAfPublicKey(flags)); + publicKeyTokenSpan = { nullptr, 0 }; } uint32_t majorVersion; @@ -648,7 +651,7 @@ namespace flags, assemblyName, assemblyCulture, - { publicKeyToken.data(), publicKeyToken.size() }, + publicKeyTokenSpan, targetAssembly)); if (hr == S_OK)