aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-03-03 11:11:16 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-03-03 11:11:16 +0100
commit609779086301a600f4282a629d586bba6b6a485c (patch)
tree0f29dd18b05d3c75cb9b5f6f94d7b3807aeea087 /src
parent885d709393caabd346299c6d6ec8ea57b8a11628 (diff)
Fix segfault in headerCallback()
https://hydra.nixos.org/build/168594664
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/flake/flakeref.cc6
-rw-r--r--src/libstore/filetransfer.cc2
-rw-r--r--src/libutil/util.cc4
-rwxr-xr-xsrc/nix-channel/nix-channel.cc2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/libexpr/flake/flakeref.cc b/src/libexpr/flake/flakeref.cc
index 930ed9ccd..c1eae413f 100644
--- a/src/libexpr/flake/flakeref.cc
+++ b/src/libexpr/flake/flakeref.cc
@@ -98,7 +98,7 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
if (std::regex_match(url, match, flakeRegex)) {
auto parsedURL = ParsedURL{
.url = url,
- .base = "flake:" + std::string(match[1]),
+ .base = "flake:" + match.str(1),
.scheme = "flake",
.authority = "",
.path = match[1],
@@ -106,12 +106,12 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
return std::make_pair(
FlakeRef(Input::fromURL(parsedURL), ""),
- percentDecode(std::string(match[6])));
+ percentDecode(match.str(6)));
}
else if (std::regex_match(url, match, pathUrlRegex)) {
std::string path = match[1];
- std::string fragment = percentDecode(std::string(match[3]));
+ std::string fragment = percentDecode(match.str(3));
if (baseDir) {
/* Check if 'url' is a path (either absolute or relative
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index 255b42c49..c46262299 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -197,7 +197,7 @@ struct curlFileTransfer : public FileTransfer
result.etag = "";
result.data.clear();
result.bodySize = 0;
- statusMsg = trim((std::string &) match[1]);
+ statusMsg = trim(match.str(1));
acceptRanges = false;
encoding = "";
} else {
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 229bebbe6..b833038a9 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1263,9 +1263,9 @@ std::string chomp(std::string_view s)
std::string trim(std::string_view s, std::string_view 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);
- 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);
}
diff --git a/src/nix-channel/nix-channel.cc b/src/nix-channel/nix-channel.cc
index f46b90b90..cf52b03b4 100755
--- a/src/nix-channel/nix-channel.cc
+++ b/src/nix-channel/nix-channel.cc
@@ -96,7 +96,7 @@ static void update(const StringSet & channelNames)
std::smatch match;
auto urlBase = std::string(baseNameOf(url));
if (std::regex_search(urlBase, match, std::regex("(-\\d.*)$")))
- cname = cname + (std::string) match[1];
+ cname = cname + match.str(1);
std::string extraAttrs;