Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crash on non-existent port with version override #1357

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 45 additions & 2 deletions azure-pipelines/end-to-end-tests-dir/registries.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,9 @@ finally
Pop-Location
}


# test builtin registry
Write-Trace "test builtin registry with baseline"
$manifestDir = "$TestingRoot/manifest"
$manifestDir = "$TestingRoot/manifest-builtin"

New-Item -Path $manifestDir -ItemType Directory
$manifestDir = (Get-Item $manifestDir).FullName
Expand All @@ -410,3 +409,47 @@ finally
{
Pop-Location
}


# test nonexistent overrides regression (https://github.com/microsoft/vcpkg/issues/36994)
Write-Trace "test nonexistent overrides regression"
$manifestDir = "$TestingRoot/manifest-nonexistent-override"

New-Item -Path $manifestDir -ItemType Directory
$manifestDir = (Get-Item $manifestDir).FullName

Push-Location $manifestDir
try
{
$vcpkgJson = @{
"name" = "manifest-test";
"version" = "1.0.0";
"dependencies" = @(
"nonexistent"
);
"overrides" = @(@{
"name" = "nonexistent";
"version" = "0";
});
"vcpkg-configuration" = @{
"default-registry" = @{
"kind" = "git";
"repository" = "https://github.com/microsoft/vcpkg";
"baseline" = "a4b5cde7f504c1bbbbc455f4a6ee60efd9034772";
};
};
}

New-Item -Path 'vcpkg.json' -ItemType File `
-Value (ConvertTo-Json -Depth 5 -InputObject $vcpkgJson)

$out = Run-VcpkgAndCaptureOutput install @commonArgs
Throw-IfNotFailed
if (-not $out.Contains("error: nonexistent does not exist")) {
throw "Expected nonexistent package to be mentioned in the output"
}
}
finally
{
Pop-Location
}
5 changes: 5 additions & 0 deletions src/vcpkg/portfileprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ namespace vcpkg
const auto& maybe_ent = entry(version_spec.port_name);
if (auto ent = maybe_ent.get())
{
if (!ent->get())
{
return msg::format_error(msgPortDoesNotExist, msg::package_name = version_spec.port_name);
}

auto maybe_path = ent->get()->get_version(version_spec.version);
if (auto path = maybe_path.get())
{
Expand Down
Loading