From d66743b9c2045ca55eb9a7471c8faf1742dcfd26 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 21 Jan 2015 15:59:52 +0100 Subject: [PATCH] fixed a memory leak --- header_only/json.h | 2 ++ src/json.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/header_only/json.h b/header_only/json.h index ed932b9dd..bfafa4ced 100644 --- a/header_only/json.h +++ b/header_only/json.h @@ -1778,6 +1778,7 @@ json::iterator json::find(const char* key) if (type_ == value_t::object) { + delete result.oi_; result.oi_ = new object_t::iterator(value_.object->find(key)); result.invalid = (*(result.oi_) == value_.object->end()); } @@ -1791,6 +1792,7 @@ json::const_iterator json::find(const char* key) const if (type_ == value_t::object) { + delete result.oi_; result.oi_ = new object_t::const_iterator(value_.object->find(key)); result.invalid = (*(result.oi_) == value_.object->cend()); } diff --git a/src/json.cc b/src/json.cc index c6e13f802..0816c279c 100644 --- a/src/json.cc +++ b/src/json.cc @@ -1249,6 +1249,7 @@ json::iterator json::find(const char* key) if (type_ == value_t::object) { + delete result.oi_; result.oi_ = new object_t::iterator(value_.object->find(key)); result.invalid = (*(result.oi_) == value_.object->end()); } @@ -1262,6 +1263,7 @@ json::const_iterator json::find(const char* key) const if (type_ == value_t::object) { + delete result.oi_; result.oi_ = new object_t::const_iterator(value_.object->find(key)); result.invalid = (*(result.oi_) == value_.object->cend()); }