Permalink
Browse files

Coverity: resource leak

Eliminate a theoretical memory leak. Theoretical because in practice it
can only happen if the situation is already FUBAR in which case the leak
probably doesn't matter.

Coverity CID#253834
  • Loading branch information...
krader1961 committed Nov 7, 2018
1 parent f79d421 commit 6bc588b1b0fad741fc8a55366dcf85f7612768e2
Showing with 7 additions and 6 deletions.
  1. +7 −6 src/lib/libast/sfio/sfpoll.c
@@ -98,14 +98,13 @@ int sfpoll(Sfio_t **fa, int n, int tm) {
np = -1;
if (c > 0) {
struct pollfd *fds;
/* construct the poll array */
// Construct the poll array.
for (m = 0, r = 0; r < c; ++r, ++m) {
f = fa[check[r]];
if (HASAUXFD(f)) m += 1;
}
fds = malloc(m * sizeof(struct pollfd));
struct pollfd *fds = malloc(m * sizeof(struct pollfd));
if (!fds) {
free(status);
return -1;
@@ -132,10 +131,12 @@ int sfpoll(Sfio_t **fa, int n, int tm) {
}
while ((np = SFPOLL(fds, m, tm)) < 0) {
if (errno == eintr || errno == EAGAIN)
if (errno == eintr || errno == EAGAIN) {
errno = 0;
else
} else {
free(fds);
goto report;
}
}
if (np > 0) /* poll succeeded */
np = c;

0 comments on commit 6bc588b

Please sign in to comment.