aboutsummaryrefslogtreecommitdiff
path: root/bpkg
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-11-18 12:33:25 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-11-18 12:33:25 +0300
commit97dab717d3542dcf86e01eb2ca16fe771e9d8886 (patch)
treeff4d1c7f4b8a435b249ce1f4700595100d8806e8 /bpkg
parentb243f9043caa82d0e9d0d0f5fbeb586dfa632bf6 (diff)
Fix crashing on depends manifest values specifying earliest release in version constraint
Diffstat (limited to 'bpkg')
-rw-r--r--bpkg/satisfaction.cxx15
-rw-r--r--bpkg/satisfaction.test.cxx2
2 files changed, 13 insertions, 4 deletions
diff --git a/bpkg/satisfaction.cxx b/bpkg/satisfaction.cxx
index c3c4995..79222c0 100644
--- a/bpkg/satisfaction.cxx
+++ b/bpkg/satisfaction.cxx
@@ -62,14 +62,21 @@ namespace bpkg
// (see libbpkg/manifest.hxx for details). That's why we normalize
// endpoint versions prior to comparison.
//
- auto norm = [] (const version& v, bool min, bool open) -> version
+ auto norm = [] (const version& v, bool min, bool open)
{
+ // Return the version as is if the revision is present or this is an
+ // earliest release (for which the revision is meaningless).
+ //
+ // We could probably avoid copying of versions that don't require
+ // normalization but let's keep it simple for now.
+ //
+ if (v.revision || (v.release && v.release->empty ()))
+ return v;
+
return version (v.epoch,
v.upstream,
v.release,
- v.revision ? v.revision :
- (min && !open) || (!min && open) ? 0 :
- uint16_t (~0),
+ (min && !open) || (!min && open) ? 0 : uint16_t (~0),
v.iteration);
};
diff --git a/bpkg/satisfaction.test.cxx b/bpkg/satisfaction.test.cxx
index 4857e0d..5a0cd05 100644
--- a/bpkg/satisfaction.test.cxx
+++ b/bpkg/satisfaction.test.cxx
@@ -47,6 +47,8 @@ namespace bpkg
assert (!satisfies (vc ("[1.0 2.0]"), vc ("[1.0 2.0+0)")));
assert (!satisfies (vc ("[1.0 2.0]"), vc ("[1.0 2.0+1)")));
+ assert (satisfies (vc ("^1.0.0"), vc ("^1.0.0")));
+
return 0;
}
}