mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-18 19:28:16 +00:00
[YAML] Plug a memory leak
The destructor of BlockScalarNode is never called. Store the contained string in BumpPtrAllocated memory instead. llvm-svn: 237614
This commit is contained in:
parent
4662acc8ae
commit
624b011af1
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user