diff options
author | roubert@google.com <roubert@google.com@38ededc0-08b8-5190-f2ac-b31f878777ad> | 2014-07-19 00:18:30 +0000 |
---|---|---|
committer | roubert@google.com <roubert@google.com@38ededc0-08b8-5190-f2ac-b31f878777ad> | 2014-07-19 00:18:30 +0000 |
commit | 2c4e35aa3533e453c4a2b9d1aded31d90e7f2066 (patch) | |
tree | 59b9bd8848e7a14dc9d4ee4d71daf79cdc4a6a57 | |
parent | 54a60127ec33ff2c28b1934d75cb17c5c51b9f43 (diff) | |
download | src-2c4e35aa3533e453c4a2b9d1aded31d90e7f2066.tar.gz |
Fix memory corruption bug in LookupKey::FromLookupKey().
Copy nodes_ only if other object is a different object.
R=rouslan@chromium.org
BUG=
Review URL: https://codereview.appspot.com/117950046
git-svn-id: http://libaddressinput.googlecode.com/svn/trunk@307 38ededc0-08b8-5190-f2ac-b31f878777ad
-rw-r--r-- | cpp/src/lookup_key.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/cpp/src/lookup_key.cc b/cpp/src/lookup_key.cc index fbd9a50..c0c7b86 100644 --- a/cpp/src/lookup_key.cc +++ b/cpp/src/lookup_key.cc @@ -109,7 +109,8 @@ void LookupKey::FromLookupKey(const LookupKey& parent, assert(parent.nodes_.size() < arraysize(kHierarchy)); assert(!child_node.empty()); - nodes_ = parent.nodes_; + // Copy its nodes if this isn't the parent object. + if (this != &parent) nodes_ = parent.nodes_; AddressField child_field = kHierarchy[nodes_.size()]; nodes_.insert(std::make_pair(child_field, child_node)); } |