Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
fuse, persist: fix leaf dumping code
Browse files Browse the repository at this point in the history
In the node leaf dumping code, verify that iter->pointers is not NULL
before attempting to access the array.
  • Loading branch information
artagnon committed Aug 29, 2012
1 parent 611a8da commit e446e54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions fuse.c
Expand Up @@ -136,7 +136,7 @@ static int phoenixfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler
if (filler(buf, (const char *) vfr->name, &st, 0))
return -ENOMEM;
}
if (iter->pointers[BTREE_ORDER - 1] != NULL)
if (iter->pointers && iter->pointers[BTREE_ORDER - 1] != NULL)
iter = iter->pointers[BTREE_ORDER - 1];
else
break;
Expand Down Expand Up @@ -668,7 +668,7 @@ int phoenixfs_fuse(int argc, char *argv[])
(const char *) dr->name);
mkdir(xpath, S_IRUSR | S_IWUSR | S_IXUSR);
}
if (iter->pointers[BTREE_ORDER - 1] != NULL)
if (iter->pointers && iter->pointers[BTREE_ORDER - 1] != NULL)
iter = iter->pointers[BTREE_ORDER - 1];
else
break;
Expand Down
6 changes: 3 additions & 3 deletions persist.c
Expand Up @@ -95,7 +95,7 @@ static void dump_vfr_tree(struct node *root, FILE *outfile)
/* Write the actual file records in chronological order */
dump_frs(vfr, start_rev, rev_nr, outfile);
}
if (iter->pointers[BTREE_ORDER - 1] != NULL)
if (iter->pointers && iter->pointers[BTREE_ORDER - 1] != NULL)
iter = iter->pointers[BTREE_ORDER - 1];
else
break;
Expand Down Expand Up @@ -128,7 +128,7 @@ void dump_dr_tree(struct node *root, FILE *outfile)
while (1) {
for (i = 0; i < iter->num_keys; i++)
num_keys++;
if (iter->pointers[BTREE_ORDER - 1] != NULL)
if (iter->pointers && iter->pointers[BTREE_ORDER - 1] != NULL)
iter = iter->pointers[BTREE_ORDER - 1];
else
break;
Expand All @@ -154,7 +154,7 @@ void dump_dr_tree(struct node *root, FILE *outfile)

dump_vfr_tree(dr->vroot, outfile);
}
if (iter->pointers[BTREE_ORDER - 1] != NULL)
if (iter->pointers && iter->pointers[BTREE_ORDER - 1] != NULL)
iter = iter->pointers[BTREE_ORDER - 1];
else
break;
Expand Down

0 comments on commit e446e54

Please sign in to comment.