MALLOC()/FREE() are not to be used for variable sized allocations.
This commit is contained in:
parent
de3878349f
commit
b94e29816f
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cd9660_vnops.c,v 1.58 2000/05/27 16:03:56 jdolecek Exp $ */
|
||||
/* $NetBSD: cd9660_vnops.c,v 1.59 2000/08/03 03:39:52 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994
|
||||
|
@ -469,8 +469,7 @@ cd9660_readdir(v)
|
|||
idp->cookies = NULL;
|
||||
else {
|
||||
ncookies = uio->uio_resid / 16;
|
||||
MALLOC(cookies, off_t *, ncookies * sizeof(off_t), M_TEMP,
|
||||
M_WAITOK);
|
||||
cookies = malloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
|
||||
idp->cookies = cookies;
|
||||
idp->ncookies = ncookies;
|
||||
}
|
||||
|
@ -591,7 +590,7 @@ cd9660_readdir(v)
|
|||
|
||||
if (ap->a_ncookies != NULL) {
|
||||
if (error)
|
||||
FREE(cookies, M_TEMP);
|
||||
free(cookies, M_TEMP);
|
||||
else {
|
||||
/*
|
||||
* Work out the number of cookies actually used.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fdesc_vnops.c,v 1.55 2000/05/27 04:52:39 thorpej Exp $ */
|
||||
/* $NetBSD: fdesc_vnops.c,v 1.56 2000/08/03 03:41:17 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -725,7 +725,7 @@ fdesc_readdir(v)
|
|||
|
||||
if (ap->a_ncookies) {
|
||||
ncookies = min(ncookies, (nfdesc_targets - i));
|
||||
MALLOC(cookies, off_t *, ncookies * sizeof(off_t),
|
||||
cookies = malloc(ncookies * sizeof(off_t),
|
||||
M_TEMP, M_WAITOK);
|
||||
*ap->a_cookies = cookies;
|
||||
*ap->a_ncookies = ncookies;
|
||||
|
@ -762,7 +762,8 @@ fdesc_readdir(v)
|
|||
} else {
|
||||
if (ap->a_ncookies) {
|
||||
ncookies = min(ncookies, (fdp->fd_nfiles + 2));
|
||||
MALLOC(cookies, off_t *, ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
|
||||
cookies = malloc(ncookies * sizeof(off_t),
|
||||
M_TEMP, M_WAITOK);
|
||||
*ap->a_cookies = cookies;
|
||||
*ap->a_ncookies = ncookies;
|
||||
}
|
||||
|
@ -795,7 +796,7 @@ fdesc_readdir(v)
|
|||
}
|
||||
|
||||
if (ap->a_ncookies && error) {
|
||||
FREE(*ap->a_cookies, M_TEMP);
|
||||
free(*ap->a_cookies, M_TEMP);
|
||||
*ap->a_ncookies = 0;
|
||||
*ap->a_cookies = NULL;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kernfs_vnops.c,v 1.69 2000/07/14 07:21:50 thorpej Exp $ */
|
||||
/* $NetBSD: kernfs_vnops.c,v 1.70 2000/08/03 03:41:18 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -638,8 +638,7 @@ kernfs_readdir(v)
|
|||
if (ap->a_ncookies) {
|
||||
nc = uio->uio_resid / UIO_MX;
|
||||
nc = min(nc, (nkern_targets - i));
|
||||
MALLOC(cookies, off_t *, nc * sizeof(off_t), M_TEMP,
|
||||
M_WAITOK);
|
||||
cookies = malloc(nc * sizeof(off_t), M_TEMP, M_WAITOK);
|
||||
*ap->a_cookies = cookies;
|
||||
}
|
||||
|
||||
|
@ -672,7 +671,7 @@ kernfs_readdir(v)
|
|||
|
||||
if (ap->a_ncookies) {
|
||||
if (error) {
|
||||
FREE(*ap->a_cookies, M_TEMP);
|
||||
free(*ap->a_cookies, M_TEMP);
|
||||
*ap->a_ncookies = 0;
|
||||
*ap->a_cookies = NULL;
|
||||
} else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: procfs_vnops.c,v 1.71 2000/06/28 02:44:07 mrg Exp $ */
|
||||
/* $NetBSD: procfs_vnops.c,v 1.72 2000/08/03 03:41:18 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Jan-Simon Pendry
|
||||
|
@ -894,7 +894,7 @@ procfs_readdir(v)
|
|||
|
||||
if (ap->a_ncookies) {
|
||||
ncookies = min(ncookies, (nproc_targets - i));
|
||||
MALLOC(cookies, off_t *, ncookies * sizeof (off_t),
|
||||
cookies = malloc(ncookies * sizeof (off_t),
|
||||
M_TEMP, M_WAITOK);
|
||||
*ap->a_cookies = cookies;
|
||||
}
|
||||
|
@ -940,7 +940,7 @@ procfs_readdir(v)
|
|||
* XXX Potentially allocating too much space here,
|
||||
* but I'm lazy. This loop needs some work.
|
||||
*/
|
||||
MALLOC(cookies, off_t *, ncookies * sizeof (off_t),
|
||||
cookies = malloc(ncookies * sizeof (off_t),
|
||||
M_TEMP, M_WAITOK);
|
||||
*ap->a_cookies = cookies;
|
||||
}
|
||||
|
@ -1022,7 +1022,7 @@ procfs_readdir(v)
|
|||
if (ap->a_ncookies) {
|
||||
if (error) {
|
||||
if (cookies)
|
||||
FREE(*ap->a_cookies, M_TEMP);
|
||||
free(*ap->a_cookies, M_TEMP);
|
||||
*ap->a_ncookies = 0;
|
||||
*ap->a_cookies = NULL;
|
||||
} else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ntfs_vnops.c,v 1.28 2000/07/30 09:29:28 simonb Exp $ */
|
||||
/* $NetBSD: ntfs_vnops.c,v 1.29 2000/08/03 03:41:54 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -686,8 +686,7 @@ ntfs_readdir(ap)
|
|||
MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
|
||||
M_TEMP, M_WAITOK);
|
||||
#else /* defined(__NetBSD__) */
|
||||
MALLOC(cookies, off_t *, ncookies * sizeof(off_t),
|
||||
M_TEMP, M_WAITOK);
|
||||
cookies = malloc(ncookies * sizeof(off_t), M_TEMP, M_WAITOK);
|
||||
#endif
|
||||
for (dp = dpStart, cookiep = cookies, i=0;
|
||||
i < ncookies;
|
||||
|
|
Loading…
Reference in New Issue