summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcache.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-02-25 16:46:42 +0100
committerJulian Andres Klode <jak@debian.org>2016-02-25 16:46:42 +0100
commit9de2fd4d117e57824f4a0795efa7379995a804cb (patch)
treeacaa850fc728a1fe8ec7768b5999b98bf9845faa /apt-pkg/pkgcache.cc
parent2c53226b72e7e58cdd9b42af46cb3d05da89809e (diff)
Fix crash with empty architecture list
If the architecture list is empty somehow, fail normally. LP: #1549819
Diffstat (limited to 'apt-pkg/pkgcache.cc')
-rw-r--r--apt-pkg/pkgcache.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index c9c338e1e..503f85657 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -184,10 +184,12 @@ bool pkgCache::ReMap(bool const &Errorchecks)
// Check the architecture
std::vector<std::string> archs = APT::Configuration::getArchitectures();
- std::vector<std::string>::const_iterator a = archs.begin();
- std::string list = *a;
- for (++a; a != archs.end(); ++a)
- list.append(",").append(*a);
+ std::string list = "";
+ for (auto const & arch : archs) {
+ if (!list.empty())
+ list.append(",");
+ list.append(arch);
+ }
if (_config->Find("APT::Architecture") != StrP + HeaderP->Architecture ||
list != StrP + HeaderP->GetArchitectures())
return _error->Error(_("The package cache was built for different architectures: %s vs %s"), StrP + HeaderP->GetArchitectures(), list.c_str());