Update.
* io/fts.c: Update from BSD to fix memory leaks. 2001-12-25 Dmitry V. Levin <ldv@alt-linux.org>
This commit is contained in:
parent
c2f5916e8c
commit
2903810a7a
|
@ -1,3 +1,7 @@
|
||||||
|
2001-12-25 Dmitry V. Levin <ldv@alt-linux.org>
|
||||||
|
|
||||||
|
* io/fts.c: Update from BSD to fix memory leaks.
|
||||||
|
|
||||||
2001-12-25 Dmitry V. Levin <ldv@alt-linux.org>
|
2001-12-25 Dmitry V. Levin <ldv@alt-linux.org>
|
||||||
|
|
||||||
* crypt/md5-crypt.c: Realloc error handling memory leak fix.
|
* crypt/md5-crypt.c: Realloc error handling memory leak fix.
|
||||||
|
|
23
io/fts.c
23
io/fts.c
|
@ -934,12 +934,17 @@ fts_sort(sp, head, nitems)
|
||||||
* 40 so don't realloc one entry at a time.
|
* 40 so don't realloc one entry at a time.
|
||||||
*/
|
*/
|
||||||
if (nitems > sp->fts_nitems) {
|
if (nitems > sp->fts_nitems) {
|
||||||
|
struct _ftsent **a;
|
||||||
|
|
||||||
sp->fts_nitems = nitems + 40;
|
sp->fts_nitems = nitems + 40;
|
||||||
if ((sp->fts_array = realloc(sp->fts_array,
|
if ((a = realloc(sp->fts_array,
|
||||||
(size_t)(sp->fts_nitems * sizeof(FTSENT *)))) == NULL) {
|
(size_t)(sp->fts_nitems * sizeof(FTSENT *)))) == NULL) {
|
||||||
|
free(sp->fts_array);
|
||||||
|
sp->fts_array = NULL;
|
||||||
sp->fts_nitems = 0;
|
sp->fts_nitems = 0;
|
||||||
return (head);
|
return (head);
|
||||||
}
|
}
|
||||||
|
sp->fts_array = a;
|
||||||
}
|
}
|
||||||
for (ap = sp->fts_array, p = head; p; p = p->fts_link)
|
for (ap = sp->fts_array, p = head; p; p = p->fts_link)
|
||||||
*ap++ = p;
|
*ap++ = p;
|
||||||
|
@ -1016,6 +1021,8 @@ fts_palloc(sp, more)
|
||||||
FTS *sp;
|
FTS *sp;
|
||||||
size_t more;
|
size_t more;
|
||||||
{
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
sp->fts_pathlen += more + 256;
|
sp->fts_pathlen += more + 256;
|
||||||
/*
|
/*
|
||||||
* Check for possible wraparound. In an FTS, fts_pathlen is
|
* Check for possible wraparound. In an FTS, fts_pathlen is
|
||||||
|
@ -1023,14 +1030,22 @@ fts_palloc(sp, more)
|
||||||
* We limit fts_pathlen to USHRT_MAX to be safe in both cases.
|
* We limit fts_pathlen to USHRT_MAX to be safe in both cases.
|
||||||
*/
|
*/
|
||||||
if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) {
|
if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) {
|
||||||
if (sp->fts_path)
|
if (sp->fts_path) {
|
||||||
free(sp->fts_path);
|
free(sp->fts_path);
|
||||||
sp->fts_path = NULL;
|
sp->fts_path = NULL;
|
||||||
|
}
|
||||||
|
sp->fts_path = NULL;
|
||||||
__set_errno (ENAMETOOLONG);
|
__set_errno (ENAMETOOLONG);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
sp->fts_path = realloc(sp->fts_path, sp->fts_pathlen);
|
p = realloc(sp->fts_path, sp->fts_pathlen);
|
||||||
return (sp->fts_path == NULL);
|
if (p == NULL) {
|
||||||
|
free(sp->fts_path);
|
||||||
|
sp->fts_path = NULL;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
sp->fts_path = p;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue