summaryrefslogtreecommitdiff
path: root/usr.bin/patch/inp.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-07-16 16:06:54 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-07-16 16:06:54 +0000
commitf58738aceeb6ea2e2a00fa3c259f7fd8ada1fb49 (patch)
treec1410ee9862d9392bf782096a81ff07aed5a7cf2 /usr.bin/patch/inp.c
parentd2521f3995b7976ca1866c0ce01b59a3ad6f8590 (diff)
Do not produce garbage if the patch file contains invalid line numbers.
ok millert@ tedu@
Diffstat (limited to 'usr.bin/patch/inp.c')
-rw-r--r--usr.bin/patch/inp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index a60d48aa138..51f29033b0c 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: inp.c,v 1.9 2002/07/04 04:22:48 deraadt Exp $ */
+/* $OpenBSD: inp.c,v 1.10 2003/07/16 16:06:53 otto Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: inp.c,v 1.9 2002/07/04 04:22:48 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: inp.c,v 1.10 2003/07/16 16:06:53 otto Exp $";
#endif /* not lint */
#include "EXTERN.h"
@@ -320,8 +320,10 @@ ifetch(line,whichbuf)
Reg1 LINENUM line;
int whichbuf; /* ignored when file in memory */
{
- if (line < 1 || line > input_lines)
- return "";
+ if (line < 1 || line > input_lines) {
+ say2("No such line %ld in input file, ignoring\n", line);
+ return NULL;
+ }
if (using_plan_a)
return i_ptr[line];
else {