diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-12-29 15:57:15 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-12-29 15:57:15 +0000 |
commit | d1dddedf7893fe70ed5d429485c8bcd0ab43f285 (patch) | |
tree | 99420c13234130854769150b8d81f5fe1d2528e3 /sunrpc | |
parent | 9403ec5d23e7dc209361b3dbae2fdc184e1684aa (diff) | |
download | glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.zip glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar.gz glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar.bz2 |
Realloc error handling memory leak fix.
Diffstat (limited to 'sunrpc')
-rw-r--r-- | sunrpc/svc.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sunrpc/svc.c b/sunrpc/svc.c index 6357d51..5260634 100644 --- a/sunrpc/svc.c +++ b/sunrpc/svc.c @@ -86,6 +86,8 @@ xprt_register (SVCXPRT *xprt) if (sock < _rpc_dtablesize ()) { + struct pollfd *new_svc_pollfd; + xports[sock] = xprt; if (sock < FD_SETSIZE) FD_SET (sock, &svc_fdset); @@ -100,11 +102,13 @@ xprt_register (SVCXPRT *xprt) return; } - ++svc_max_pollfd; - svc_pollfd = realloc (svc_pollfd, - sizeof (struct pollfd) * svc_max_pollfd); - if (svc_pollfd == NULL) /* Out of memory */ + new_svc_pollfd = (struct pollfd *) realloc (svc_pollfd, + sizeof (struct pollfd) + * (svc_max_pollfd + 1)); + if (new_svc_pollfd == NULL) /* Out of memory */ return; + svc_pollfd = new_svc_pollfd; + ++svc_max_pollfd; svc_pollfd[svc_max_pollfd - 1].fd = sock; svc_pollfd[svc_max_pollfd - 1].events = (POLLIN | POLLPRI | |