From 66eb722481860e38bfd1ca8128101270df0369b8 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Sat, 29 Nov 2014 20:35:28 -0500 Subject: [PATCH] minor change --- kson.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kson.h b/kson.h index 5555bfe..8618433 100644 --- a/kson.h +++ b/kson.h @@ -58,6 +58,7 @@ extern "C" { static inline const kson_node_t *kson_by_key(const kson_node_t *p, const char *key) { long i; + if (p->type != KSON_TYPE_BRACE) return 0; for (i = 0; i < (long)p->n; ++i) { const kson_node_t *q = p->v.child[i]; if (q->key && strcmp(q->key, key) == 0) @@ -68,6 +69,7 @@ static inline const kson_node_t *kson_by_key(const kson_node_t *p, const char *k static inline const kson_node_t *kson_by_index(const kson_node_t *p, long i) { + if (p->type != KSON_TYPE_BRACKET) return 0; return 0 <= i && i < (long)p->n? p->v.child[i] : 0; } -- 2.47.3