}
ret = 0;
- *ufs_branches = malloc(sizeof(struct unionfs_branch));
+ *ufs_branches = malloc(sizeof(struct unionfs_branch)*(len+1));
if (!(*ufs_branches)) {
errno = ENOMEM;
return -1;
for (i = 0; i <= len; i++) {
if (FD_ISSET(i, &branchlist)) {
- *ufs_branches = realloc(*ufs_branches,
- sizeof(struct unionfs_branch)*(ret+1));
- (*ufs_branches)[ret].path = malloc(strlen(branches[ret]+1));
- strcpy((*ufs_branches)[ret].path, branches[i]);
+ (*ufs_branches)[ret].path = strdup(branches[i]);
(*ufs_branches)[ret].perms = branchperms[i];
ret++;
}