From 1153778f92f731fdf73dccfc253d2ae9361b45a3 Mon Sep 17 00:00:00 2001 From: Dong Xie Date: Mon, 22 Apr 2019 08:37:02 -0600 Subject: [PATCH] fix a bug in copy constructor of ParsedJson::iterator. (#146) --- singleheader/simdjson.cpp | 2 +- src/parsedjsoniterator.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/singleheader/simdjson.cpp b/singleheader/simdjson.cpp index 2a85f24d..e99a48fe 100644 --- a/singleheader/simdjson.cpp +++ b/singleheader/simdjson.cpp @@ -1618,7 +1618,7 @@ ParsedJson::iterator::iterator(const iterator &o): current_val(o.current_val), depthindex(nullptr) { depthindex = new scopeindex_t[pj.depthcapacity]; if(depthindex != nullptr) { - memcpy(o.depthindex, depthindex, pj.depthcapacity * sizeof(depthindex[0])); + memcpy(depthindex, o.depthindex, pj.depthcapacity * sizeof(depthindex[0])); } else { tape_length = 0; } diff --git a/src/parsedjsoniterator.cpp b/src/parsedjsoniterator.cpp index b85cf31d..044acab6 100644 --- a/src/parsedjsoniterator.cpp +++ b/src/parsedjsoniterator.cpp @@ -34,7 +34,7 @@ ParsedJson::iterator::iterator(const iterator &o): current_val(o.current_val), depthindex(nullptr) { depthindex = new scopeindex_t[pj.depthcapacity]; if(depthindex != nullptr) { - memcpy(o.depthindex, depthindex, pj.depthcapacity * sizeof(depthindex[0])); + memcpy(depthindex, o.depthindex, pj.depthcapacity * sizeof(depthindex[0])); } else { tape_length = 0; }