From 27143e990f80d2f2e35c2986e2f1e814846af453 Mon Sep 17 00:00:00 2001 From: John McPherson Date: Fri, 13 Jun 2025 15:14:02 -0700 Subject: [PATCH 1/2] Don't deref potential null --- src/AppInstallerCLICore/Workflows/PortableFlow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp index 7a34b52623..86d4450894 100644 --- a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp @@ -111,9 +111,10 @@ namespace AppInstaller::CLI::Workflow { Manifest::ScopeEnum scope = Manifest::ScopeEnum::Unknown; bool isUpdate = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerExecutionUseUpdate); - if (isUpdate) + auto installedVersion = context.Get(); + if (isUpdate && installedVersion) { - IPackageVersion::Metadata installationMetadata = context.Get()->GetMetadata(); + IPackageVersion::Metadata installationMetadata = installedVersion->GetMetadata(); auto installerScopeItr = installationMetadata.find(Repository::PackageVersionMetadata::InstalledScope); if (installerScopeItr != installationMetadata.end()) { From b1405e31cb73553b535fe79870f763f4233703a1 Mon Sep 17 00:00:00 2001 From: John McPherson Date: Sat, 14 Jun 2025 13:01:32 -0700 Subject: [PATCH 2/2] Ensure that we actually have the value present --- src/AppInstallerCLICore/Workflows/PortableFlow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp index 86d4450894..36c654e237 100644 --- a/src/AppInstallerCLICore/Workflows/PortableFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/PortableFlow.cpp @@ -111,7 +111,11 @@ namespace AppInstaller::CLI::Workflow { Manifest::ScopeEnum scope = Manifest::ScopeEnum::Unknown; bool isUpdate = WI_IsFlagSet(context.GetFlags(), Execution::ContextFlag::InstallerExecutionUseUpdate); - auto installedVersion = context.Get(); + std::shared_ptr installedVersion; + if (context.Contains(Execution::Data::InstalledPackageVersion)) + { + installedVersion = context.Get(); + } if (isUpdate && installedVersion) { IPackageVersion::Metadata installationMetadata = installedVersion->GetMetadata();