]> git.saurik.com Git - apt.git/commitdiff
Corrected determining if regexp matched.
authorEugene V. Lyubimkin <jackyf@1501-debian>
Sat, 25 Oct 2008 19:49:22 +0000 (22:49 +0300)
committerEugene V. Lyubimkin <jackyf@1501-debian>
Sat, 25 Oct 2008 19:49:22 +0000 (22:49 +0300)
apt-pkg/algorithms.cc

index bd59a4749f0b400e66f7c7ee21b1681059d49f00..6f30a52da5f2b5213c0f583d5537072b496e3abc 100644 (file)
@@ -1348,8 +1348,8 @@ bool ListUpdate(pkgAcquireStatus &Stat,
          regex_t userPassRegex;
          regcomp(&userPassRegex, "\\://(\\w+)\\:(\\w+)@", REG_EXTENDED);
          regmatch_t userPassMatch;
-         regexec(&userPassRegex, descUri.c_str(), 1, &userPassMatch, 0);
-         if (userPassMatch.rm_so != -1) // regexp matched
+         int regMatchResult = regexec(&userPassRegex, descUri.c_str(), 1, &userPassMatch, 0);
+         if (regMatchResult == 0 && userPassMatch.rm_so != -1) // regexp matched
          {
          // really stripping
                 size_t stripStart = userPassMatch.rm_so + 3;
@@ -1357,6 +1357,7 @@ bool ListUpdate(pkgAcquireStatus &Stat,
                 descUri = descUri.substr(0, stripStart) +
             descUri.substr(stripEnd, string::npos);
       }
+      regfree(&userPassRegex);
 
       _error->Warning(_("Failed to fetch %s  %s\n"), descUri.c_str(),
              (*I)->ErrorText.c_str());