Skip to content

Commit

Permalink
samples: sockets: socketpair: mitigate negative index
Browse files Browse the repository at this point in the history
Fixes #25780
Coverity-CID: 210612

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
  • Loading branch information
cfriedt authored and carlescufi committed Jun 3, 2020
1 parent 9cc82a0 commit fb9f6a4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions samples/net/sockets/socketpair/src/socketpair_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ int main(int argc, char *argv[])

fd = fds[i].fd;
idx = fd_to_idx(fd, ctx, ARRAY_SIZE(ctx));
if (idx < 0) {
printf("failed to map fd %d to index\n", fd);
continue;
}

if ((fds[i].revents & POLLIN) != 0) {

Expand Down

0 comments on commit fb9f6a4

Please sign in to comment.