summaryrefslogtreecommitdiffstats
path: root/usr.bin/tail/read.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2008-06-02 06:01:15 +0000
committerotto <otto@openbsd.org>2008-06-02 06:01:15 +0000
commit88365b46367dfdcd86d6f27c6e3ddbfbe098a8dc (patch)
treeab22dafd343bb2f6d569eac75adb421b541ac1df /usr.bin/tail/read.c
parentregen (diff)
downloadwireguard-openbsd-88365b46367dfdcd86d6f27c6e3ddbfbe098a8dc.tar.xz
wireguard-openbsd-88365b46367dfdcd86d6f27c6e3ddbfbe098a8dc.zip
fix double free which can happen if the last line has no newline;
from Matthew Dempsky; ok ray@ millert@
Diffstat (limited to 'usr.bin/tail/read.c')
-rw-r--r--usr.bin/tail/read.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/tail/read.c b/usr.bin/tail/read.c
index 2ad182787ad..efe53e2a035 100644
--- a/usr.bin/tail/read.c
+++ b/usr.bin/tail/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.12 2007/09/29 12:31:28 otto Exp $ */
+/* $OpenBSD: read.c,v 1.13 2008/06/02 06:01:15 otto Exp $ */
/* $NetBSD: read.c,v 1.4 1994/11/23 07:42:07 jtc Exp $ */
/*-
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: read.c,v 1.12 2007/09/29 12:31:28 otto Exp $";
+static char rcsid[] = "$OpenBSD: read.c,v 1.13 2008/06/02 06:01:15 otto Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -199,6 +199,7 @@ lines(FILE *fp, off_t off)
if (cnt) {
lines[recno].l = sp;
lines[recno].len = cnt;
+ sp = NULL;
if (++recno == off) {
wrap = 1;
recno = 0;