lightning-cli: fix handling of complex objects with -H.

I crashed it using `-H listconfigs`

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: cli: fixed crash with `listconfigs` in `-H` mode
This commit is contained in:
Rusty Russell
2020-09-08 14:50:13 +09:30
committed by neil saitug
parent 5bac63c6a3
commit fb013f9d02
2 changed files with 190 additions and 1 deletions

View File

@@ -65,7 +65,7 @@ static size_t human_readable(const char *buffer, const jsmntok_t *t, char term)
case JSMN_OBJECT:
/* Elide single-field objects */
if (t->size == 1)
return human_readable(buffer, t + 2, '\n') + 3;
return human_readable(buffer, t + 2, '\n') + 2;
n = 1;
for (i = 0; i < t->size; i++) {
n += human_readable(buffer, t + n, '=');