From 11e19ee69027e9e6ed77db2b1b4789afb7848d6a Mon Sep 17 00:00:00 2001 From: Taeer Bar-Yam Date: Fri, 31 Oct 2025 21:52:10 +0100 Subject: [PATCH] libexpr: shrink ExprWith by 8 bytes Correct bound on prevWith Co-authored-by: John Ericson --- src/libexpr/include/nix/expr/nixexpr.hh | 2 +- src/libexpr/nixexpr.cc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libexpr/include/nix/expr/nixexpr.hh b/src/libexpr/include/nix/expr/nixexpr.hh index fd7ed2a67..1fb4d0642 100644 --- a/src/libexpr/include/nix/expr/nixexpr.hh +++ b/src/libexpr/include/nix/expr/nixexpr.hh @@ -637,8 +637,8 @@ struct ExprLet : Expr struct ExprWith : Expr { PosIdx pos; + uint32_t prevWith; Expr *attrs, *body; - size_t prevWith; ExprWith * parentWith; ExprWith(const PosIdx & pos, Expr * attrs, Expr * body) : pos(pos) diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index b183f1bbf..81ba5f09f 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -523,6 +523,7 @@ void ExprWith::bindVars(EvalState & es, const std::shared_ptr & prevWith = 0; for (curEnv = env.get(), level = 1; curEnv; curEnv = curEnv->up.get(), level++) if (curEnv->isWith) { + assert(level <= std::numeric_limits::max()); prevWith = level; break; }