From 78d58253159b6013ae30463d02a76534a2de552a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 12 Mar 2018 10:55:18 -0700 Subject: [PATCH] ircd::json: Deeper copying on value copy ctor. --- ircd/json.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ircd/json.cc b/ircd/json.cc index 267c210d8..894d7fa06 100644 --- a/ircd/json.cc +++ b/ircd/json.cc @@ -1210,19 +1210,19 @@ ircd::json::value::value(const value &other) ,alloc{other.alloc} ,floats{other.floats} { - if(alloc && serial) + if(serial) { - create_string(len, [this] + create_string(len, [&other] (mutable_buffer &buffer) { - consume(buffer, copy(buffer, string_view{*this})); + consume(buffer, copy(buffer, string_view{other})); }); } else switch(type) { case OBJECT: { - if(serial || !object) + if(!object) break; const size_t count(this->len); @@ -1236,7 +1236,7 @@ ircd::json::value::value(const value &other) case ARRAY: { - if(serial || !array) + if(!array) break; const size_t count(this->len); @@ -1250,13 +1250,13 @@ ircd::json::value::value(const value &other) case STRING: { - if(serial || !alloc || !string) + if(!string) break; - create_string(serialized(*this), [this] + create_string(len, [&other] (mutable_buffer &buffer) { - json::stringify(buffer, *this); + copy(buffer, const_buffer{other.string, other.len}); }); break; }