aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derivations.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 05:51:23 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 05:51:23 +0100
commit5e182235cb7e7b601c5e010c298bf17415113ce0 (patch)
treed7dcfb54efbb5277184e0fcda9aa169b75e771ea /src/libstore/derivations.cc
parent30f3298e9dafa3bc4422c29dad972e320ad70e01 (diff)
Merge pull request #7348 from thufschmitt/dont-use-vlas
Remove the usage of VLAs in the code (cherry picked from commit ac4431e9d016e62fb5dc9ae36833bd0c6cdadeec) Change-Id: Ifbf5fbfc2e27122362a2aaea4b62c7cf3ca46b1a
Diffstat (limited to 'src/libstore/derivations.cc')
-rw-r--r--src/libstore/derivations.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index 7ea4d50e6..6678227fe 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -152,11 +152,10 @@ StorePath writeDerivation(Store & store,
/* Read string `s' from stream `str'. */
static void expect(std::istream & str, std::string_view s)
{
- char s2[s.size()];
- str.read(s2, s.size());
- std::string_view s2View { s2, s.size() };
- if (s2View != s)
- throw FormatError("expected string '%s', got '%s'", s, s2View);
+ for (auto & c : s) {
+ if (str.get() != c)
+ throw FormatError("expected string '%1%'", s);
+ }
}