diff options
-rw-r--r-- | usr.bin/sed/main.c | 2 | ||||
-rw-r--r-- | usr.bin/sed/process.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c index 029a79f..dafb0bd 100644 --- a/usr.bin/sed/main.c +++ b/usr.bin/sed/main.c @@ -411,6 +411,8 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) unlink(tmpfname); if ((outfile = fopen(tmpfname, "w")) == NULL) err(1, "%s", fname); + if (outfile != NULL && outfile != stdout) + fclose(outfile); fchown(fileno(outfile), sb.st_uid, sb.st_gid); fchmod(fileno(outfile), sb.st_mode & ALLPERMS); outfname = tmpfname; diff --git a/usr.bin/sed/process.c b/usr.bin/sed/process.c index cdfba81..daabfd8 100644 --- a/usr.bin/sed/process.c +++ b/usr.bin/sed/process.c @@ -324,7 +324,7 @@ applies(struct s_command *cp) } else r = 1; } - } else if (MATCH(cp->a1)) { + } else if (cp->a1 && MATCH(cp->a1)) { /* * If the second address is a number less than or * equal to the line number first selected, only |