From: Heng Li Date: Sun, 30 Nov 2014 01:35:28 +0000 (-0500) Subject: minor change X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=66eb722481860e38bfd1ca8128101270df0369b8;p=klib.git minor change --- 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; }