Fix segfault in headerCallback()

https://hydra.nixos.org/build/168594664
This commit is contained in:
Eelco Dolstra 2022-03-03 11:11:16 +01:00
parent 885d709393
commit 6097790863
4 changed files with 7 additions and 7 deletions

View file

@ -98,7 +98,7 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
if (std::regex_match(url, match, flakeRegex)) { if (std::regex_match(url, match, flakeRegex)) {
auto parsedURL = ParsedURL{ auto parsedURL = ParsedURL{
.url = url, .url = url,
.base = "flake:" + std::string(match[1]), .base = "flake:" + match.str(1),
.scheme = "flake", .scheme = "flake",
.authority = "", .authority = "",
.path = match[1], .path = match[1],
@ -106,12 +106,12 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
return std::make_pair( return std::make_pair(
FlakeRef(Input::fromURL(parsedURL), ""), FlakeRef(Input::fromURL(parsedURL), ""),
percentDecode(std::string(match[6]))); percentDecode(match.str(6)));
} }
else if (std::regex_match(url, match, pathUrlRegex)) { else if (std::regex_match(url, match, pathUrlRegex)) {
std::string path = match[1]; std::string path = match[1];
std::string fragment = percentDecode(std::string(match[3])); std::string fragment = percentDecode(match.str(3));
if (baseDir) { if (baseDir) {
/* Check if 'url' is a path (either absolute or relative /* Check if 'url' is a path (either absolute or relative

View file

@ -197,7 +197,7 @@ struct curlFileTransfer : public FileTransfer
result.etag = ""; result.etag = "";
result.data.clear(); result.data.clear();
result.bodySize = 0; result.bodySize = 0;
statusMsg = trim((std::string &) match[1]); statusMsg = trim(match.str(1));
acceptRanges = false; acceptRanges = false;
encoding = ""; encoding = "";
} else { } else {

View file

@ -1263,9 +1263,9 @@ std::string chomp(std::string_view s)
std::string trim(std::string_view s, std::string_view whitespace) std::string trim(std::string_view s, std::string_view whitespace)
{ {
auto i = s.find_first_not_of(whitespace); auto i = s.find_first_not_of(whitespace);
if (i == std::string_view::npos) return ""; if (i == s.npos) return "";
auto j = s.find_last_not_of(whitespace); auto j = s.find_last_not_of(whitespace);
return std::string(s, i, j == std::string::npos ? j : j - i + 1); return std::string(s, i, j == s.npos ? j : j - i + 1);
} }

View file

@ -96,7 +96,7 @@ static void update(const StringSet & channelNames)
std::smatch match; std::smatch match;
auto urlBase = std::string(baseNameOf(url)); auto urlBase = std::string(baseNameOf(url));
if (std::regex_search(urlBase, match, std::regex("(-\\d.*)$"))) if (std::regex_search(urlBase, match, std::regex("(-\\d.*)$")))
cname = cname + (std::string) match[1]; cname = cname + match.str(1);
std::string extraAttrs; std::string extraAttrs;