summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/configuration.cc14
-rw-r--r--apt-pkg/contrib/configuration.h1
-rw-r--r--apt-pkg/depcache.h2
3 files changed, 13 insertions, 4 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 81cc87d15..cc7093fe2 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -857,19 +857,27 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config)
{
regfree(p);
delete p;
+ clearPatterns();
_error->Warning("Regex compilation error for '%s' in configuration option '%s'",
s->c_str(), Config);
+ return;
}
- }
-
+ }
+ if (strings.size() == 0)
+ patterns.push_back(NULL);
}
/*}}}*/
// MatchAgainstConfig Destructor /*{{{*/
Configuration::MatchAgainstConfig::~MatchAgainstConfig()
{
+ clearPatterns();
+}
+void Configuration::MatchAgainstConfig::clearPatterns()
+{
for(std::vector<regex_t *>::const_iterator p = patterns.begin();
p != patterns.end(); ++p)
{
+ if (*p == NULL) continue;
regfree(*p);
delete *p;
}
@@ -880,7 +888,7 @@ bool Configuration::MatchAgainstConfig::Match(char const * str) const
{
for(std::vector<regex_t *>::const_iterator p = patterns.begin();
p != patterns.end(); ++p)
- if (regexec(*p, str, 0, 0, 0) == 0)
+ if (*p != NULL && regexec(*p, str, 0, 0, 0) == 0)
return true;
return false;
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index cbe18e4e5..175c1bef3 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -109,6 +109,7 @@ class Configuration
class MatchAgainstConfig
{
std::vector<regex_t *> patterns;
+ void clearPatterns();
public:
MatchAgainstConfig(char const * Config);
diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h
index 45276dc95..08e683558 100644
--- a/apt-pkg/depcache.h
+++ b/apt-pkg/depcache.h
@@ -186,7 +186,7 @@ class pkgDepCache : protected pkgCache::Namespace
class DefaultRootSetFunc : public InRootSetFunc, public Configuration::MatchAgainstConfig
{
public:
- DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverRemove") {};
+ DefaultRootSetFunc() : Configuration::MatchAgainstConfig("APT::NeverAutoRemove") {};
virtual ~DefaultRootSetFunc() {};
bool InRootSet(const pkgCache::PkgIterator &pkg) { return pkg.end() == true && Match(pkg.Name()); };