Fix a stun attribute leak.
In https://cs.chromium.org/chromium/src/third_party/webrtc/p2p/base/stun.cc?rcl=1474384719&l=352, if read returned false, the created attr would not be released. BUG=chromium:648064 R=skvlad@webrtc.org Review URL: https://codereview.webrtc.org/2357733002 . Cr-Commit-Position: refs/heads/master@{#14357}
This commit is contained in:
parent
d3af58bdab
commit
3e02430587
@ -340,7 +340,8 @@ bool StunMessage::Read(ByteBufferReader* buf) {
|
||||
if (!buf->ReadUInt16(&attr_length))
|
||||
return false;
|
||||
|
||||
StunAttribute* attr = CreateAttribute(attr_type, attr_length);
|
||||
std::unique_ptr<StunAttribute> attr(
|
||||
CreateAttribute(attr_type, attr_length));
|
||||
if (!attr) {
|
||||
// Skip any unknown or malformed attributes.
|
||||
if ((attr_length % 4) != 0) {
|
||||
@ -351,7 +352,8 @@ bool StunMessage::Read(ByteBufferReader* buf) {
|
||||
} else {
|
||||
if (!attr->Read(buf))
|
||||
return false;
|
||||
attrs_->push_back(attr);
|
||||
// TODO(honghaiz): Change |attrs_| to be a vector of unique_ptrs.
|
||||
attrs_->push_back(attr.release());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user