diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-07-21 21:01:46 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-07-21 21:01:46 +0000 |
commit | 1ee7a3b476b82c26d5d9344276dbff547d6c40b5 (patch) | |
tree | a4e581675640c07a2a8d8d85d5cd66b3cd2d614e /usr.bin/patch | |
parent | 56d815eed8c7b92a612fa8da15d69a9c5d93311e (diff) |
Back out invalid line number fix. It core dumps in some cases. Problem found by
marc@.
ok henning@
Diffstat (limited to 'usr.bin/patch')
-rw-r--r-- | usr.bin/patch/inp.c | 6 | ||||
-rw-r--r-- | usr.bin/patch/patch.c | 11 |
2 files changed, 6 insertions, 11 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c index f06a61b9c17..9928ab6ed2e 100644 --- a/usr.bin/patch/inp.c +++ b/usr.bin/patch/inp.c @@ -1,7 +1,7 @@ -/* $OpenBSD: inp.c,v 1.14 2003/07/21 14:32:21 deraadt Exp $ */ +/* $OpenBSD: inp.c,v 1.15 2003/07/21 21:01:45 otto Exp $ */ #ifndef lint -static char rcsid[] = "$OpenBSD: inp.c,v 1.14 2003/07/21 14:32:21 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: inp.c,v 1.15 2003/07/21 21:01:45 otto Exp $"; #endif /* not lint */ #include "EXTERN.h" @@ -320,7 +320,7 @@ ifetch(LINENUM line, int whichbuf) { if (line < 1 || line > input_lines) { say("No such line %ld in input file, ignoring\n", line); - return NULL; + return ""; } if (using_plan_a) return i_ptr[line]; diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index c09c0f86eab..d3a10bcb36c 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.21 2003/07/21 14:32:21 deraadt Exp $ */ +/* $OpenBSD: patch.c,v 1.22 2003/07/21 21:01:45 otto Exp $ */ /* * patch - a program to apply diffs to original files @@ -27,7 +27,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: patch.c,v 1.21 2003/07/21 14:32:21 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: patch.c,v 1.22 2003/07/21 21:01:45 otto Exp $"; #endif /* not lint */ #include "INTERN.h" @@ -838,11 +838,8 @@ dump_line(LINENUM line) { char *s, R_newline = '\n'; - s = ifetch(line, 0); - if (s == NULL) - return; /* Note: string is not null terminated. */ - for (; putc(*s, ofp) != R_newline; s++) + for (s=ifetch(line, 0); putc(*s, ofp) != R_newline; s++) ; } @@ -874,8 +871,6 @@ patch_match(LINENUM base, LINENUM offset, LINENUM fuzz) bool similar(char *a, char *b, int len) { - if (a == NULL || b == NULL) - return FALSE; while (len) { if (isspace(*b)) { /* whitespace (or \n) to match? */ if (!isspace(*a)) /* no corresponding whitespace? */ |