about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--third_party/nix/src/libexpr/eval.cc5
-rw-r--r--third_party/nix/src/libexpr/value.hh2
2 files changed, 3 insertions, 4 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index 2a0aba1a4c8b..e15741811738 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -434,13 +434,12 @@ Value* EvalState::addPrimOp(const std::string& name, size_t arity,
     primOp(*this, noPos, nullptr, v);
     return addConstant(name, v);
   }
-  Value* v = allocValue();
   std::string name2 =
       std::string(name, 0, 2) == "__" ? std::string(name, 2) : name;
   Symbol sym = symbols.Create(name2);
-  // Even though PrimOp doesn't need tracing, it needs to be collected.
+  Value* v = allocValue();
   v->type = tPrimOp;
-  v->primOp = new PrimOp(primOp, arity, sym);
+  v->primOp = std::make_shared<PrimOp>(primOp, arity, sym);
   staticBaseEnv.vars[symbols.Create(name)] = baseEnvDispl;
   baseEnv.values[baseEnvDispl++] = v;
   baseEnv.values[0]->attrs->push_back(Attr(sym, v));
diff --git a/third_party/nix/src/libexpr/value.hh b/third_party/nix/src/libexpr/value.hh
index 980d9affbb51..82021c77c41b 100644
--- a/third_party/nix/src/libexpr/value.hh
+++ b/third_party/nix/src/libexpr/value.hh
@@ -100,7 +100,7 @@ struct Value {
     NixThunk thunk;
     NixApp app;  // TODO(tazjin): "app"?
     NixLambda lambda;
-    PrimOp* primOp;
+    std::shared_ptr<PrimOp> primOp;
     NixPrimOpApp primOpApp;
     NixFloat fpoint;
   };