Index: webrtc/p2p/base/stun.cc |
diff --git a/webrtc/p2p/base/stun.cc b/webrtc/p2p/base/stun.cc |
index 78b188afef6445d73241c1f65a11e02c35d51725..8c5c92bbc949b5a166990b32dc26452aa23d7aea 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)); |
skvlad
2016/09/20 23:14:21
You could also change CreateAttribute itself to re
honghaiz3
2016/09/21 17:36:31
I will leave the improvement to a future CL. Add a
|
if (!attr) { |
// Skip any unknown or malformed attributes. |
if ((attr_length % 4) != 0) { |
@@ -351,7 +352,7 @@ bool StunMessage::Read(ByteBufferReader* buf) { |
} else { |
if (!attr->Read(buf)) |
return false; |
- attrs_->push_back(attr); |
+ attrs_->push_back(attr.release()); |
} |
} |