diff options
-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) { |