summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-11-21 21:26:00 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-11-21 21:26:00 +0000
commite3a7340c3aa111b73910da8aa88d51d3f11a48fa (patch)
tree66e4805dca2ea7bf88f127af1b98ab1cffd46587 /usr.bin
parent86fc5efa641a16e46b9f5c1bbbe39c0544a773fd (diff)
madvise(sequential) the mmap()ed file and plug an fd leak on mmap() failure; millert@ ok
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/patch/inp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index 3e6464234b7..156848dea91 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inp.c,v 1.29 2003/09/28 07:55:19 otto Exp $ */
+/* $OpenBSD: inp.c,v 1.30 2003/11/21 21:25:59 mickey Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: inp.c,v 1.29 2003/09/28 07:55:19 otto Exp $";
+static const char rcsid[] = "$OpenBSD: inp.c,v 1.30 2003/11/21 21:25:59 mickey Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -252,10 +252,13 @@ plan_a(const char *filename)
if (i_womp == MAP_FAILED) {
perror("mmap failed");
i_womp = NULL;
+ close(ifd);
return false;
}
close(ifd);
+ if (i_size)
+ madvise(i_womp, i_size, MADV_SEQUENTIAL);
/* estimate the number of lines */
lines_allocated = i_size / 25;