Commit d66743b9 authored by Niels's avatar Niels

fixed a memory leak

parent bbc45eb4
...@@ -1778,6 +1778,7 @@ json::iterator json::find(const char* key) ...@@ -1778,6 +1778,7 @@ json::iterator json::find(const char* key)
if (type_ == value_t::object) if (type_ == value_t::object)
{ {
delete result.oi_;
result.oi_ = new object_t::iterator(value_.object->find(key)); result.oi_ = new object_t::iterator(value_.object->find(key));
result.invalid = (*(result.oi_) == value_.object->end()); result.invalid = (*(result.oi_) == value_.object->end());
} }
...@@ -1791,6 +1792,7 @@ json::const_iterator json::find(const char* key) const ...@@ -1791,6 +1792,7 @@ json::const_iterator json::find(const char* key) const
if (type_ == value_t::object) if (type_ == value_t::object)
{ {
delete result.oi_;
result.oi_ = new object_t::const_iterator(value_.object->find(key)); result.oi_ = new object_t::const_iterator(value_.object->find(key));
result.invalid = (*(result.oi_) == value_.object->cend()); result.invalid = (*(result.oi_) == value_.object->cend());
} }
......
...@@ -1249,6 +1249,7 @@ json::iterator json::find(const char* key) ...@@ -1249,6 +1249,7 @@ json::iterator json::find(const char* key)
if (type_ == value_t::object) if (type_ == value_t::object)
{ {
delete result.oi_;
result.oi_ = new object_t::iterator(value_.object->find(key)); result.oi_ = new object_t::iterator(value_.object->find(key));
result.invalid = (*(result.oi_) == value_.object->end()); result.invalid = (*(result.oi_) == value_.object->end());
} }
...@@ -1262,6 +1263,7 @@ json::const_iterator json::find(const char* key) const ...@@ -1262,6 +1263,7 @@ json::const_iterator json::find(const char* key) const
if (type_ == value_t::object) if (type_ == value_t::object)
{ {
delete result.oi_;
result.oi_ = new object_t::const_iterator(value_.object->find(key)); result.oi_ = new object_t::const_iterator(value_.object->find(key));
result.invalid = (*(result.oi_) == value_.object->cend()); result.invalid = (*(result.oi_) == value_.object->cend());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment