mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 13:06:01 +01:00
libexpr: Fix Value::mkList for empty lists
This code used to save the pointer to a small list allocated on the stack to the Value, which is unintended.
This commit is contained in:
parent
3c331b7ef3
commit
2ed2c79721
1 changed files with 11 additions and 3 deletions
|
|
@ -993,12 +993,20 @@ public:
|
|||
|
||||
void mkList(const ListBuilder & builder) noexcept
|
||||
{
|
||||
if (builder.size == 1)
|
||||
switch (builder.size) {
|
||||
case 0:
|
||||
setStorage(List{.size = 0, .elems = nullptr});
|
||||
break;
|
||||
case 1:
|
||||
setStorage(std::array<Value *, 2>{builder.inlineElems[0], nullptr});
|
||||
else if (builder.size == 2)
|
||||
break;
|
||||
case 2:
|
||||
setStorage(std::array<Value *, 2>{builder.inlineElems[0], builder.inlineElems[1]});
|
||||
else
|
||||
break;
|
||||
default:
|
||||
setStorage(List{.size = builder.size, .elems = builder.elems});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void mkThunk(Env * e, Expr * ex) noexcept
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue