mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
Fix resource leak and dereference after NULL.
process.c: Protect access against NULL. main.c: Prevent outfile overwrite resource leak. CID: 271181 CID: 1006930 Obtained from: NetBSD MFC after: 3 days
This commit is contained in:
parent
c7d7e597b4
commit
fc04dce059
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277802
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user