summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2008-06-02 06:01:16 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2008-06-02 06:01:16 +0000
commit68ab07e7c49d67530c8adb6ce5c9bbd475602b52 (patch)
tree2a0ed59907362677daa87f833e9ae468d1e09be9
parent5c7ff56b609dd821bc4bdd40ce5820cb2e250859 (diff)
fix double free which can happen if the last line has no newline;
from Matthew Dempsky; ok ray@ millert@
-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;