Kaynağa Gözat

Corrected determining if regexp matched.

Eugene V. Lyubimkin 17 yıl önce
ebeveyn
işleme
2d6f9accbc
1 değiştirilmiş dosya ile 3 ekleme ve 2 silme
  1. 3 2
      apt-pkg/algorithms.cc

+ 3 - 2
apt-pkg/algorithms.cc

@@ -1348,8 +1348,8 @@ bool ListUpdate(pkgAcquireStatus &Stat,
 	  regex_t userPassRegex;
 	  regex_t userPassRegex;
 	  regcomp(&userPassRegex, "\\://(\\w+)\\:(\\w+)@", REG_EXTENDED);
 	  regcomp(&userPassRegex, "\\://(\\w+)\\:(\\w+)@", REG_EXTENDED);
 	  regmatch_t userPassMatch;
 	  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
          // really stripping
 		 size_t stripStart = userPassMatch.rm_so + 3;
 		 size_t stripStart = userPassMatch.rm_so + 3;
@@ -1357,6 +1357,7 @@ bool ListUpdate(pkgAcquireStatus &Stat,
 		 descUri = descUri.substr(0, stripStart) +
 		 descUri = descUri.substr(0, stripStart) +
             descUri.substr(stripEnd, string::npos);
             descUri.substr(stripEnd, string::npos);
       }
       }
+      regfree(&userPassRegex);
 
 
       _error->Warning(_("Failed to fetch %s  %s\n"), descUri.c_str(),
       _error->Warning(_("Failed to fetch %s  %s\n"), descUri.c_str(),
 	      (*I)->ErrorText.c_str());
 	      (*I)->ErrorText.c_str());