Misc Coverity fixes for tail(1)
CID 1006402: Initialize stack variable CID 271580: Don't leak memory when ENOMEM. Reported by: Coverity CID: 271580 1006402 MFC after: 4 weeks Sponsored by: Spectra Logic Corp
This commit is contained in:
parent
1e0c121f3a
commit
2277edc8a6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=311340
@ -117,6 +117,7 @@ r_reg(FILE *fp, const char *fn, enum STYLE style, off_t off, struct stat *sbp)
|
||||
map.start = NULL;
|
||||
map.mapoff = map.maxoff = size;
|
||||
map.fd = fileno(fp);
|
||||
map.maplen = 0;
|
||||
|
||||
/*
|
||||
* Last char is special, ignore whether newline or not. Note that
|
||||
@ -205,7 +206,13 @@ r_buf(FILE *fp, const char *fn)
|
||||
(tl->l = malloc(BSZ)) == NULL) {
|
||||
if (!mark)
|
||||
err(1, "malloc");
|
||||
tl = enomem ? tl->next : mark;
|
||||
if (enomem)
|
||||
tl = tl->next;
|
||||
else {
|
||||
if (tl)
|
||||
free(tl);
|
||||
tl = mark;
|
||||
}
|
||||
enomem += tl->len;
|
||||
} else if (mark) {
|
||||
tl->next = mark;
|
||||
|
Loading…
Reference in New Issue
Block a user