diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2014-11-04 17:17:06 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2014-11-04 17:17:06 +0000 |
commit | 9bc5438d3f8a85c95a135e88c7b9cf8627b60b49 (patch) | |
tree | fa842f6a477b43d4281b3bf611394edc0bad011c /lib/libc | |
parent | 36cfa5131e308b3bc9fae8e0ddab049607873bea (diff) |
Fix memory leak on reallocarray() failure introduced by conversion
from calloc().
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/rpc/svc_run.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c index 84099982656..2be4f25745d 100644 --- a/lib/libc/rpc/svc_run.c +++ b/lib/libc/rpc/svc_run.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svc_run.c,v 1.22 2014/10/22 23:10:30 millert Exp $ */ +/* $OpenBSD: svc_run.c,v 1.23 2014/11/04 17:17:05 millert Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -45,13 +45,14 @@ void svc_run(void) { - struct pollfd *pfd = NULL; + struct pollfd *pfd = NULL, *newp; int nready, saved_max_pollfd = 0; for (;;) { if (svc_max_pollfd > saved_max_pollfd) { - pfd = reallocarray(pfd, svc_max_pollfd, sizeof(*pfd)); - if (pfd == NULL) { + newp = reallocarray(pfd, svc_max_pollfd, sizeof(*pfd)); + if (newp == NULL) { + free(pfd); perror("svc_run"); /* XXX */ return; /* XXX */ } @@ -68,6 +69,7 @@ svc_run(void) free(pfd); return; /* XXX */ case 0: + /* should not happen */ continue; default: svc_getreq_poll(pfd, nready); |