From c6a94a7f3556c8dc998630aa65b4e812c7898ad1 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 17 Oct 2020 19:36:11 -0500 Subject: Update verutil precedence rules to check for invalid after release labels. --- src/dutil/verutil.cpp | 57 +++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 27 deletions(-) (limited to 'src/dutil/verutil.cpp') diff --git a/src/dutil/verutil.cpp b/src/dutil/verutil.cpp index f362f413..835dde81 100644 --- a/src/dutil/verutil.cpp +++ b/src/dutil/verutil.cpp @@ -85,22 +85,6 @@ DAPI_(HRESULT) VerCompareParsedVersions( ExitFunction(); } - if (pVersion1->fInvalid) - { - if (!pVersion2->fInvalid) - { - ExitFunction1(nResult = -1); - } - else - { - fCompareMetadata = TRUE; - } - } - else if (pVersion2->fInvalid) - { - ExitFunction1(nResult = 1); - } - if (pVersion1->cReleaseLabels) { if (pVersion2->cReleaseLabels) @@ -132,6 +116,22 @@ DAPI_(HRESULT) VerCompareParsedVersions( } } + if (pVersion1->fInvalid) + { + if (!pVersion2->fInvalid) + { + ExitFunction1(nResult = -1); + } + else + { + fCompareMetadata = TRUE; + } + } + else if (pVersion2->fInvalid) + { + ExitFunction1(nResult = 1); + } + if (fCompareMetadata) { hr = CompareVersionSubstring(pVersion1->sczVersion + pVersion1->cchMetadataOffset, -1, pVersion2->sczVersion + pVersion2->cchMetadataOffset, -1, &nResult); @@ -191,20 +191,23 @@ DAPI_(HRESULT) VerCopyVersion( pCopy->dwPatch = pSource->dwPatch; pCopy->dwRevision = pSource->dwRevision; - hr = MemEnsureArraySize(reinterpret_cast(&pCopy->rgReleaseLabels), 0, sizeof(VERUTIL_VERSION_RELEASE_LABEL), pSource->cReleaseLabels); - VerExitOnFailure(hr, "Failed to allocate memory for Verutil version release labels copies."); + if (pSource->cReleaseLabels) + { + hr = MemEnsureArraySize(reinterpret_cast(&pCopy->rgReleaseLabels), 0, sizeof(VERUTIL_VERSION_RELEASE_LABEL), pSource->cReleaseLabels); + VerExitOnFailure(hr, "Failed to allocate memory for Verutil version release labels copies."); - pCopy->cReleaseLabels = pSource->cReleaseLabels; + pCopy->cReleaseLabels = pSource->cReleaseLabels; - for (DWORD i = 0; i < pCopy->cReleaseLabels; ++i) - { - VERUTIL_VERSION_RELEASE_LABEL* pSourceLabel = pSource->rgReleaseLabels + i; - VERUTIL_VERSION_RELEASE_LABEL* pCopyLabel = pCopy->rgReleaseLabels + i; + for (DWORD i = 0; i < pCopy->cReleaseLabels; ++i) + { + VERUTIL_VERSION_RELEASE_LABEL* pSourceLabel = pSource->rgReleaseLabels + i; + VERUTIL_VERSION_RELEASE_LABEL* pCopyLabel = pCopy->rgReleaseLabels + i; - pCopyLabel->cchLabelOffset = pSourceLabel->cchLabelOffset; - pCopyLabel->cchLabel = pSourceLabel->cchLabel; - pCopyLabel->fNumeric = pSourceLabel->fNumeric; - pCopyLabel->dwValue = pSourceLabel->dwValue; + pCopyLabel->cchLabelOffset = pSourceLabel->cchLabelOffset; + pCopyLabel->cchLabel = pSourceLabel->cchLabel; + pCopyLabel->fNumeric = pSourceLabel->fNumeric; + pCopyLabel->dwValue = pSourceLabel->dwValue; + } } pCopy->cchMetadataOffset = pSource->cchMetadataOffset; -- cgit v1.2.3-55-g6feb