From a377495cfba1cafc26985acb57ec04facf25afe2 Mon Sep 17 00:00:00 2001 From: fvdl Date: Tue, 3 Mar 1998 13:44:48 +0000 Subject: [PATCH] Only free cookiebuf when sure that the vop actually allocated it. --- sys/compat/ibcs2/ibcs2_misc.c | 7 ++++--- sys/compat/linux/common/linux_break.c | 7 ++++--- sys/compat/linux/common/linux_misc.c | 7 ++++--- sys/compat/linux/common/linux_misc_notalpha.c | 7 ++++--- sys/compat/linux/common/linux_oldmmap.c | 7 ++++--- sys/compat/linux/common/linux_oldolduname.c | 7 ++++--- sys/compat/linux/common/linux_oldselect.c | 7 ++++--- sys/compat/linux/common/linux_olduname.c | 7 ++++--- sys/compat/linux/common/linux_pipe.c | 7 ++++--- sys/compat/linux/linux_misc.c | 7 ++++--- sys/compat/linux/multiarch/linux_break.c | 7 ++++--- sys/compat/linux/multiarch/linux_misc_notalpha.c | 7 ++++--- sys/compat/linux/multiarch/linux_oldmmap.c | 7 ++++--- sys/compat/linux/multiarch/linux_oldolduname.c | 7 ++++--- sys/compat/linux/multiarch/linux_oldselect.c | 7 ++++--- sys/compat/linux/multiarch/linux_olduname.c | 7 ++++--- sys/compat/linux/multiarch/linux_pipe.c | 7 ++++--- sys/compat/sunos/sunos_misc.c | 7 ++++--- sys/compat/svr4/svr4_misc.c | 12 +++++++----- 19 files changed, 79 insertions(+), 59 deletions(-) diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c index 44516b7c3561..dcfbcabb1510 100644 --- a/sys/compat/ibcs2/ibcs2_misc.c +++ b/sys/compat/ibcs2/ibcs2_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ibcs2_misc.c,v 1.33 1998/03/01 02:22:58 fvdl Exp $ */ +/* $NetBSD: ibcs2_misc.c,v 1.34 1998/03/03 13:47:48 fvdl Exp $ */ /* * Copyright (c) 1994, 1995, 1998 Scott Bartram @@ -362,7 +362,7 @@ ibcs2_sys_getdents(p, v, retval) struct ibcs2_dirent idb; off_t off; /* true file offset */ int buflen, error, eofflag; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -447,7 +447,8 @@ eof: *retval = SCARG(uap, nbytes) - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return (error); } diff --git a/sys/compat/linux/common/linux_break.c b/sys/compat/linux/common/linux_break.c index e84a9fad6537..da9a7904a85f 100644 --- a/sys/compat/linux/common/linux_break.c +++ b/sys/compat/linux/common/linux_break.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_break.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_break.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/common/linux_misc.c b/sys/compat/linux/common/linux_misc.c index 74cb40137119..59303f70cb4b 100644 --- a/sys/compat/linux/common/linux_misc.c +++ b/sys/compat/linux/common/linux_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_misc.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/common/linux_misc_notalpha.c b/sys/compat/linux/common/linux_misc_notalpha.c index 0cb89f778f50..69a955a07232 100644 --- a/sys/compat/linux/common/linux_misc_notalpha.c +++ b/sys/compat/linux/common/linux_misc_notalpha.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc_notalpha.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_misc_notalpha.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/common/linux_oldmmap.c b/sys/compat/linux/common/linux_oldmmap.c index 5a28dc9601fb..39fa48bd31f4 100644 --- a/sys/compat/linux/common/linux_oldmmap.c +++ b/sys/compat/linux/common/linux_oldmmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldmmap.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_oldmmap.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/common/linux_oldolduname.c b/sys/compat/linux/common/linux_oldolduname.c index 6f5a0b4b540e..f28286e97a9c 100644 --- a/sys/compat/linux/common/linux_oldolduname.c +++ b/sys/compat/linux/common/linux_oldolduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldolduname.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_oldolduname.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/common/linux_oldselect.c b/sys/compat/linux/common/linux_oldselect.c index c71b4e0bc406..c9aaca962b42 100644 --- a/sys/compat/linux/common/linux_oldselect.c +++ b/sys/compat/linux/common/linux_oldselect.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldselect.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_oldselect.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/common/linux_olduname.c b/sys/compat/linux/common/linux_olduname.c index f4cf063e6e41..ffbc71d4677e 100644 --- a/sys/compat/linux/common/linux_olduname.c +++ b/sys/compat/linux/common/linux_olduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_olduname.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_olduname.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/common/linux_pipe.c b/sys/compat/linux/common/linux_pipe.c index 4d6bc3d6fcd0..5d7f4f90e07e 100644 --- a/sys/compat/linux/common/linux_pipe.c +++ b/sys/compat/linux/common/linux_pipe.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pipe.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_pipe.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 74cb40137119..59303f70cb4b 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_misc.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/multiarch/linux_break.c b/sys/compat/linux/multiarch/linux_break.c index e84a9fad6537..da9a7904a85f 100644 --- a/sys/compat/linux/multiarch/linux_break.c +++ b/sys/compat/linux/multiarch/linux_break.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_break.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_break.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/multiarch/linux_misc_notalpha.c b/sys/compat/linux/multiarch/linux_misc_notalpha.c index 0cb89f778f50..69a955a07232 100644 --- a/sys/compat/linux/multiarch/linux_misc_notalpha.c +++ b/sys/compat/linux/multiarch/linux_misc_notalpha.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc_notalpha.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_misc_notalpha.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/multiarch/linux_oldmmap.c b/sys/compat/linux/multiarch/linux_oldmmap.c index 5a28dc9601fb..39fa48bd31f4 100644 --- a/sys/compat/linux/multiarch/linux_oldmmap.c +++ b/sys/compat/linux/multiarch/linux_oldmmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldmmap.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_oldmmap.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/multiarch/linux_oldolduname.c b/sys/compat/linux/multiarch/linux_oldolduname.c index 6f5a0b4b540e..f28286e97a9c 100644 --- a/sys/compat/linux/multiarch/linux_oldolduname.c +++ b/sys/compat/linux/multiarch/linux_oldolduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldolduname.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_oldolduname.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/multiarch/linux_oldselect.c b/sys/compat/linux/multiarch/linux_oldselect.c index c71b4e0bc406..c9aaca962b42 100644 --- a/sys/compat/linux/multiarch/linux_oldselect.c +++ b/sys/compat/linux/multiarch/linux_oldselect.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldselect.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_oldselect.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/multiarch/linux_olduname.c b/sys/compat/linux/multiarch/linux_olduname.c index f4cf063e6e41..ffbc71d4677e 100644 --- a/sys/compat/linux/multiarch/linux_olduname.c +++ b/sys/compat/linux/multiarch/linux_olduname.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_olduname.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_olduname.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/linux/multiarch/linux_pipe.c b/sys/compat/linux/multiarch/linux_pipe.c index 4d6bc3d6fcd0..5d7f4f90e07e 100644 --- a/sys/compat/linux/multiarch/linux_pipe.c +++ b/sys/compat/linux/multiarch/linux_pipe.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pipe.c,v 1.39 1998/03/01 02:23:03 fvdl Exp $ */ +/* $NetBSD: linux_pipe.c,v 1.40 1998/03/03 13:44:48 fvdl Exp $ */ /* * Copyright (c) 1995 Frank van der Linden @@ -788,7 +788,7 @@ linux_sys_getdents(p, v, retval) off_t off; /* true file offset */ int buflen, error, eofflag, nbytes, oldcall; struct vattr va; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -904,7 +904,8 @@ eof: *retval = nbytes - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c index 3ec9a3dec0b1..13bb73b7bd01 100644 --- a/sys/compat/sunos/sunos_misc.c +++ b/sys/compat/sunos/sunos_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: sunos_misc.c,v 1.88 1998/03/01 02:22:45 fvdl Exp $ */ +/* $NetBSD: sunos_misc.c,v 1.89 1998/03/03 13:46:42 fvdl Exp $ */ /* * Copyright (c) 1992, 1993 @@ -440,7 +440,7 @@ sunos_sys_getdents(p, v, retval) struct sunos_dirent idb; off_t off; /* true file offset */ int buflen, error, eofflag; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -530,7 +530,8 @@ eof: *retval = SCARG(uap, nbytes) - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return (error); } diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 174266229013..25f9e0a1ba94 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_misc.c,v 1.59 1998/03/01 02:22:50 fvdl Exp $ */ +/* $NetBSD: svr4_misc.c,v 1.60 1998/03/03 13:45:58 fvdl Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -234,7 +234,7 @@ svr4_sys_getdents64(p, v, retval) struct svr4_dirent64 idb; off_t off; /* true file offset */ int buflen, error, eofflag; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -318,7 +318,8 @@ eof: *retval = SCARG(uap, nbytes) - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; } @@ -343,7 +344,7 @@ svr4_sys_getdents(p, v, retval) struct svr4_dirent idb; off_t off; /* true file offset */ int buflen, error, eofflag; - off_t *cookiebuf, *cookie; + off_t *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -431,7 +432,8 @@ eof: *retval = SCARG(uap, nbytes) - resid; out: VOP_UNLOCK(vp, 0); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return error; }