mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 08:11:08 +00:00
Make sure fts_cur is always valid after return from fts_read.
This commit is contained in:
parent
e013caa79f
commit
0f841e93f1
9
io/fts.c
9
io/fts.c
@ -376,12 +376,14 @@ fts_read(sp)
|
|||||||
}
|
}
|
||||||
p = sp->fts_child;
|
p = sp->fts_child;
|
||||||
sp->fts_child = NULL;
|
sp->fts_child = NULL;
|
||||||
|
sp->fts_cur = p;
|
||||||
goto name;
|
goto name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to the next node on this level. */
|
/* Move to the next node on this level. */
|
||||||
next: tmp = p;
|
next: tmp = p;
|
||||||
if ((p = p->fts_link) != NULL) {
|
if ((p = p->fts_link) != NULL) {
|
||||||
|
sp->fts_cur = p;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -394,7 +396,7 @@ next: tmp = p;
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
fts_load(sp, p);
|
fts_load(sp, p);
|
||||||
return (sp->fts_cur = p);
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -420,11 +422,12 @@ next: tmp = p;
|
|||||||
name: t = sp->fts_path + NAPPEND(p->fts_parent);
|
name: t = sp->fts_path + NAPPEND(p->fts_parent);
|
||||||
*t++ = '/';
|
*t++ = '/';
|
||||||
memmove(t, p->fts_name, p->fts_namelen + 1);
|
memmove(t, p->fts_name, p->fts_namelen + 1);
|
||||||
return (sp->fts_cur = p);
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move up to the parent node. */
|
/* Move up to the parent node. */
|
||||||
p = tmp->fts_parent;
|
p = tmp->fts_parent;
|
||||||
|
sp->fts_cur = p;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
if (p->fts_level == FTS_ROOTPARENTLEVEL) {
|
if (p->fts_level == FTS_ROOTPARENTLEVEL) {
|
||||||
@ -465,7 +468,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
|
p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
|
||||||
return (sp->fts_cur = p);
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user