1
0
mirror of https://github.com/c64scene-ar/llvm-6502.git synced 2025-04-11 00:39:36 +00:00

[YAML] Plug a memory leak

The destructor of BlockScalarNode is never called. Store the contained
string in BumpPtrAllocated memory instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237614 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2015-05-18 21:11:27 +00:00
parent e4603f0daf
commit 825a528bbe
2 changed files with 7 additions and 5 deletions
include/llvm/Support
lib/Support

@ -235,8 +235,8 @@ class BlockScalarNode : public Node {
public:
BlockScalarNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
std::string &Value, StringRef RawVal)
: Node(NK_BlockScalar, D, Anchor, Tag), Value(std::move(Value)) {
StringRef Value, StringRef RawVal)
: Node(NK_BlockScalar, D, Anchor, Tag), Value(Value) {
SMLoc Start = SMLoc::getFromPointer(RawVal.begin());
SMLoc End = SMLoc::getFromPointer(RawVal.end());
SourceRange = SMRange(Start, End);
@ -250,7 +250,7 @@ public:
}
private:
std::string Value;
StringRef Value;
};
/// \brief A key and value pair. While not technically a Node under the YAML

@ -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)