diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2022-06-09 15:40:44 +0300 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-06-09 17:12:30 +0200 |
commit | 5dc97e2eeb5f2c3173f0227ef8d0d64e10cbc9cd (patch) | |
tree | 9ddab4c1bbde009b3815682fb634ca207c32bd17 | |
parent | 1b5dd9ce731f07147c998b46b5079b87e8674e30 (diff) |
Fix crashing in up_negotiate_configuration()
-rw-r--r-- | bpkg/package-configuration.cxx | 9 | ||||
-rw-r--r-- | bpkg/package-configuration.hxx | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/bpkg/package-configuration.cxx b/bpkg/package-configuration.cxx index 6ec2ea3..624de18 100644 --- a/bpkg/package-configuration.cxx +++ b/bpkg/package-configuration.cxx @@ -130,10 +130,15 @@ namespace bpkg if (da.prefer || cfg.empty ()) depc.reload_defaults (cfg); - - depc_cfgs.push_back (cfg); } + // Note that we need to collect the dependency configurations as a + // separate loop so that the stored references are not invalidated by + // operator[] (which is really a push_back() into a vector). + // + for (package_skeleton& depc: depcs) + depc_cfgs.push_back (cfgs[depc.key]); + // Step 2: execute the prefer/accept or requires clauses. // if (!(da.require diff --git a/bpkg/package-configuration.hxx b/bpkg/package-configuration.hxx index 80ededb..d6fc989 100644 --- a/bpkg/package-configuration.hxx +++ b/bpkg/package-configuration.hxx @@ -102,6 +102,8 @@ namespace bpkg class package_configurations: public small_vector<package_configuration, 1> { public: + // Note: may invalidate references. + // package_configuration& operator[] (const package_key& p) { |