diff options
Diffstat (limited to 'usr.sbin/acme-client/json.c')
| -rw-r--r-- | usr.sbin/acme-client/json.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/usr.sbin/acme-client/json.c b/usr.sbin/acme-client/json.c index a26f9097c72..db1ccf66585 100644 --- a/usr.sbin/acme-client/json.c +++ b/usr.sbin/acme-client/json.c @@ -1,4 +1,4 @@ -/* $Id: json.c,v 1.5 2016/09/13 17:13:37 deraadt Exp $ */ +/* $Id: json.c,v 1.6 2016/09/13 20:09:54 tedu Exp $ */ /* * Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -152,15 +152,25 @@ jsmnparse_free(struct parse *p) if (NULL == p) return; - for (i = 0; i < p->max; i++) - if (JSMN_ARRAY == p->nodes[i].type) - free(p->nodes[i].d.array); - else if (JSMN_OBJECT == p->nodes[i].type) - free(p->nodes[i].d.obj); - else if (JSMN_PRIMITIVE == p->nodes[i].type) - free(p->nodes[i].d.str); - else if (JSMN_STRING == p->nodes[i].type) - free(p->nodes[i].d.str); + for (i = 0; i < p->max; i++) { + struct jsmnn *n = &p->nodes[i]; + switch (n->type) { + case JSMN_ARRAY: + free(n->d.array); + break; + case JSMN_OBJECT: + free(n->d.obj); + break; + case JSMN_PRIMITIVE: + free(n->d.str); + break; + case JSMN_STRING: + free(n->d.str); + break; + case JSMN_UNDEFINED: + break; + } + } free(p->nodes); free(p); } |
