From 722e4080c3ee4ca9d7c3bd83f193314f632a2e58 Mon Sep 17 00:00:00 2001 From: Howard Kapustein Date: Wed, 1 Jun 2022 07:07:31 -0700 Subject: [PATCH] Fix URFW string-needs-deep-copy-before-XML-parser-changes-context (#2562) --- dev/UndockedRegFreeWinRT/catalog.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dev/UndockedRegFreeWinRT/catalog.cpp b/dev/UndockedRegFreeWinRT/catalog.cpp index d4faf7dcdc..02e0bb993d 100644 --- a/dev/UndockedRegFreeWinRT/catalog.cpp +++ b/dev/UndockedRegFreeWinRT/catalog.cpp @@ -188,11 +188,12 @@ HRESULT ParseFileTag(IXmlReader* xmlReader) HRESULT hr = S_OK; XmlNodeType nodeType; PCWSTR localName = nullptr; - PCWSTR fileName = nullptr; + PCWSTR value = nullptr; hr = xmlReader->MoveToAttributeByName(L"name", nullptr); RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_SXS_MANIFEST_PARSE_ERROR), hr != S_OK); - RETURN_IF_FAILED(xmlReader->GetValue(&fileName, nullptr)); - RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_SXS_MANIFEST_PARSE_ERROR), fileName == nullptr || !fileName[0]); + RETURN_IF_FAILED(xmlReader->GetValue(&value, nullptr)); + std::wstring fileName{ !value ? L"" : value }; + RETURN_HR_IF(HRESULT_FROM_WIN32(ERROR_SXS_MANIFEST_PARSE_ERROR), fileName.empty()); auto locale = _create_locale(LC_ALL, "C"); while (S_OK == xmlReader->Read(&nodeType)) { @@ -201,7 +202,7 @@ HRESULT ParseFileTag(IXmlReader* xmlReader) RETURN_IF_FAILED(xmlReader->GetLocalName(&localName, nullptr)); if (localName != nullptr && _wcsicmp_l(localName, L"activatableClass", locale) == 0) { - RETURN_IF_FAILED(ParseActivatableClassTag(xmlReader, fileName)); + RETURN_IF_FAILED(ParseActivatableClassTag(xmlReader, fileName.c_str())); } } else if (nodeType == XmlNodeType_EndElement)