From d9c7f32a9c8644acef4569509be0de8f1c82ff6c Mon Sep 17 00:00:00 2001 From: Kane York Date: Sat, 12 Sep 2020 08:39:15 -0700 Subject: fix(3p/tvix): properly zero the largest member of Value The static_assert is present to force us to change the constructor when a member grows. Change-Id: Ifa4f4a03eb7ce13cff109cf26ecf0032045905e9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1972 Tested-by: BuildkiteCI Reviewed-by: glittershark --- third_party/nix/src/libexpr/value.hh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/third_party/nix/src/libexpr/value.hh b/third_party/nix/src/libexpr/value.hh index b5a1a33cba..980d9affbb 100644 --- a/third_party/nix/src/libexpr/value.hh +++ b/third_party/nix/src/libexpr/value.hh @@ -105,7 +105,10 @@ struct Value { NixFloat fpoint; }; - Value() : type(tInt), integer(0) {} + Value() : type(tInt), attrs(nullptr) { + static_assert(offsetof(Value, attrs) + sizeof(attrs) == sizeof(Value)); + } + Value(const Value& copy); Value(Value&& move); ~Value() {} -- cgit 1.4.1