[llvm] [llvm][mustache] Fix UB in ASTNode::render() (PR #142249)
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 5 07:53:01 PDT 2025
================
@@ -560,68 +566,71 @@ void toMustacheString(const json::Value &Data, raw_ostream &OS) {
}
}
-void ASTNode::render(const json::Value &Data, raw_ostream &OS) {
- ParentContext = &Data;
+void ASTNode::render(const json::Value &CurrentCtx, raw_ostream &OS) {
+ // Set the parent context to the incoming context so that we
+ // can walk up the context tree correctly in findContext().
+ ParentContext = &CurrentCtx;
----------------
ilovepi wrote:
So, think the parent of the node at this point is default/root node. Here we're setting it to the actual parent. I don't think it needs to be reset on the way back up, since they're now fixed in the template/AST. This does make me wonder if there is a better way to set the context/parent relationships than in this recursive routine, though.
https://github.com/llvm/llvm-project/pull/142249
More information about the llvm-commits
mailing list