From 7236733edc0b7794f54ab62cecb344e0be376962 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 18 May 2015 21:11:27 +0000 Subject: [YAML] Plug a memory leak The destructor of BlockScalarNode is never called. Store the contained string in BumpPtrAllocated memory instead. llvm-svn: 237614 --- llvm/lib/Support/YAMLParser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Support/YAMLParser.cpp') diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp index 162a22bd910..41d446744fe 100644 --- a/llvm/lib/Support/YAMLParser.cpp +++ b/llvm/lib/Support/YAMLParser.cpp @@ -2377,11 +2377,13 @@ parse_property: , AnchorInfo.Range.substr(1) , TagInfo.Range , T.Range); - case Token::TK_BlockScalar: + case Token::TK_BlockScalar: { getNext(); + StringRef StrCopy = StringRef(T.Value).copy(NodeAllocator); return new (NodeAllocator) BlockScalarNode(stream.CurrentDoc, AnchorInfo.Range.substr(1), - TagInfo.Range, T.Value, T.Range); + TagInfo.Range, StrCopy, T.Range); + } case Token::TK_Key: // Don't eat the TK_Key, KeyValueNode expects it. return new (NodeAllocator) -- cgit v1.2.3