Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Unified Diff: webrtc/p2p/base/stun.cc

Issue 2357733002: Fix a stun attribute leak. (Closed)
Patch Set: . Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/stun.cc
diff --git a/webrtc/p2p/base/stun.cc b/webrtc/p2p/base/stun.cc
index 78b188afef6445d73241c1f65a11e02c35d51725..658984a64364b08058d064502a789aa11c3452e1 100644
--- a/webrtc/p2p/base/stun.cc
+++ b/webrtc/p2p/base/stun.cc
@@ -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());
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698