Skip to content

Commit

Permalink
validate the length of the correct object in yajl_tree_get
Browse files Browse the repository at this point in the history
  • Loading branch information
z00b committed May 25, 2011
1 parent 827bc98 commit 9c2948a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/yajl_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9c2948a

Please sign in to comment.