winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 603254dde60172c3924b7564e75121726e11031c
parent e8e79b85d566da4ebb0a1ee42cf72211a04eb0cb
Author: JohnMcPMS <johnmcp@microsoft.com>
Date:   Thu, 24 Mar 2022 09:54:57 -0700

Mitigate crash occuring in CompositeSource (#2043)


Diffstat:
Msrc/AppInstallerRepositoryCore/CompositeSource.cpp | 22+++++++++++++++++++++-
Msrc/AppInstallerRepositoryCore/Microsoft/SQLiteIndexSource.cpp | 4++++
2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/AppInstallerRepositoryCore/CompositeSource.cpp b/src/AppInstallerRepositoryCore/CompositeSource.cpp @@ -727,9 +727,29 @@ namespace AppInstaller::Repository for (auto&& match : installedResult.Matches) { - auto compositePackage = std::make_shared<CompositePackage>(std::move(match.Package)); + if (!match.Package) + { + // Ensure that the crash from installedVersion below is not from the actual package being null. + AICLI_LOG(Repo, Warning, << "CompositeSource: The match of the package (matched on " << + ToString(match.MatchCriteria.Field) << " => '" << match.MatchCriteria.Value << + "') was null and is being dropped from the results."); + continue; + } + + auto compositePackage = std::make_shared<CompositePackage>(match.Package); auto installedVersion = compositePackage->GetInstalledVersion(); + + if (!installedVersion) + { + // One would think that the installed version coming directly from our own installed source + // would never be null, but it is sometimes. Rather than making users suffer through crashes + // that break their entire experience, lets log a few things and then ignore this match. + AICLI_LOG(Repo, Warning, << "CompositeSource: The installed version of the package '" << + match.Package->GetProperty(PackageProperty::Id) << "' was null and is being dropped from the results."); + continue; + } + auto installedPackageData = result.GetSystemReferenceStrings(installedVersion.get()); // Create a search request to run against all available sources diff --git a/src/AppInstallerRepositoryCore/Microsoft/SQLiteIndexSource.cpp b/src/AppInstallerRepositoryCore/Microsoft/SQLiteIndexSource.cpp @@ -198,6 +198,10 @@ namespace AppInstaller::Repository::Microsoft THROW_HR(E_UNEXPECTED); } } + else + { + AICLI_LOG(Repo, Verbose, << "PackageBase: No manifest was found for the package with id# '" << m_idId << "'"); + } return result; }