Skip to content

Commit

Permalink
Coverity: resource leak
Browse files Browse the repository at this point in the history
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 6bc588b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/lib/libast/sfio/sfpoll.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ int sfpoll(Sfio_t **fa, int n, int tm) {


np = -1; np = -1;
if (c > 0) { if (c > 0) {
struct pollfd *fds; // Construct the poll array.

/* construct the poll array */
for (m = 0, r = 0; r < c; ++r, ++m) { for (m = 0, r = 0; r < c; ++r, ++m) {
f = fa[check[r]]; f = fa[check[r]];
if (HASAUXFD(f)) m += 1; if (HASAUXFD(f)) m += 1;
} }
fds = malloc(m * sizeof(struct pollfd));
struct pollfd *fds = malloc(m * sizeof(struct pollfd));
if (!fds) { if (!fds) {
free(status); free(status);
return -1; return -1;
Expand All @@ -132,10 +131,12 @@ int sfpoll(Sfio_t **fa, int n, int tm) {
} }


while ((np = SFPOLL(fds, m, tm)) < 0) { while ((np = SFPOLL(fds, m, tm)) < 0) {
if (errno == eintr || errno == EAGAIN) if (errno == eintr || errno == EAGAIN) {
errno = 0; errno = 0;
else } else {
free(fds);
goto report; goto report;
}
} }
if (np > 0) /* poll succeeded */ if (np > 0) /* poll succeeded */
np = c; np = c;
Expand Down

0 comments on commit 6bc588b

Please sign in to comment.