From 9c2948a33165c650122d131f31140c15321908f5 Mon Sep 17 00:00:00 2001 From: Rob Zuber Date: Tue, 24 May 2011 19:00:27 -0700 Subject: [PATCH] validate the length of the correct object in yajl_tree_get --- src/yajl_tree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/yajl_tree.c b/src/yajl_tree.c index 3e7da941..8f871a45 100644 --- a/src/yajl_tree.c +++ b/src/yajl_tree.c @@ -457,15 +457,17 @@ yajl_val yajl_tree_get(yajl_val n, const char ** path, yajl_type type) if (!path) return NULL; while (n && *path) { unsigned int i; + int len; if (n->type != yajl_t_object) return NULL; - for (i = 0; i < n->u.object.len; i++) { + len = n->u.object.len; + for (i = 0; i < len; i++) { if (!strcmp(*path, n->u.object.keys[i])) { n = n->u.object.values[i]; break; } } - if (i == n->u.object.len) return NULL; + if (i == len) return NULL; path++; } if (n && type != yajl_t_any && type != n->type) n = NULL;