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
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 @@
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));
}