diff options
author | Lloyd Hilaiel <lloyd@hilaiel.com> | 2011-05-25 07:11:08 -0700 |
---|---|---|
committer | Lloyd Hilaiel <lloyd@hilaiel.com> | 2011-05-25 07:11:08 -0700 |
commit | dbcba50b7785170d89bfeddaf2b41fe3f3ffacf4 (patch) | |
tree | 602855fd889caa82f37be6b51b37ecdb6c888ad9 | |
parent | 827bc9853633c088db53f514773413c419683f03 (diff) | |
parent | 9c2948a33165c650122d131f31140c15321908f5 (diff) | |
download | yajl-dbcba50b7785170d89bfeddaf2b41fe3f3ffacf4.tar.gz |
Merge pull request #36 from utahstreetlabs/tree-get-validation-error
validate the length of the correct object in yajl_tree_get
-rw-r--r-- | src/yajl_tree.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/yajl_tree.c b/src/yajl_tree.c index 3e7da94..8f871a4 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; |