diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-08-24 13:37:43 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-08-24 13:44:05 +0200 |
commit | da9beb288d2ee35b9c70513dd18f220b2dc32f16 (patch) | |
tree | 5ab71efddf30d8db28357573e5892075998d731b /src/univalue | |
parent | 561f8af45040d9b306a85023d916b3196956bfdc (diff) | |
parent | e938122b7ba8723c8cab6de78e8a9b39ad188589 (diff) |
Merge pull request #6576
e938122 Stop parsing JSON after first finished construct. (Daniel Kraft)
Diffstat (limited to 'src/univalue')
-rw-r--r-- | src/univalue/univalue_read.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/univalue/univalue_read.cpp b/src/univalue/univalue_read.cpp index 261771811d..64591234cb 100644 --- a/src/univalue/univalue_read.cpp +++ b/src/univalue/univalue_read.cpp @@ -244,16 +244,16 @@ bool UniValue::read(const char *raw) bool expectColon = false; vector<UniValue*> stack; + string tokenVal; + unsigned int consumed; enum jtokentype tok = JTOK_NONE; enum jtokentype last_tok = JTOK_NONE; - while (1) { + do { last_tok = tok; - string tokenVal; - unsigned int consumed; tok = getJsonToken(tokenVal, consumed, raw); if (tok == JTOK_NONE || tok == JTOK_ERR) - break; + return false; raw += consumed; switch (tok) { @@ -377,9 +377,11 @@ bool UniValue::read(const char *raw) default: return false; } - } + } while (!stack.empty ()); - if (stack.size() != 0) + /* Check that nothing follows the initial construct (parsed above). */ + tok = getJsonToken(tokenVal, consumed, raw); + if (tok != JTOK_NONE) return false; return true; |