With broadcast PDUs we can receive multiple replies so must make sure we
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Sat, 2 Jul 2011 02:16:37 +0000 (12:16 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Sat, 2 Jul 2011 02:16:37 +0000 (12:16 +1000)
delete the previuous unmarshalling buffer when we start over and
process the second pdu to the initial call.

Or else we will leak memory very slowly when processing broadcast RPC replies

lib/pdu.c

index 601f11023778a28bb71d83b5d1844fce49c19f22..d6e823201e99393efa9d1bd3df0988da44c27ef2 100644 (file)
--- a/lib/pdu.c
+++ b/lib/pdu.c
@@ -149,6 +149,9 @@ static int rpc_process_reply(struct rpc_context *rpc, struct rpc_pdu *pdu, XDR *
        bzero(&msg, sizeof(struct rpc_msg));
        msg.acpted_rply.ar_verf = _null_auth;
        if (pdu->xdr_decode_bufsize > 0) {
+               if (pdu->xdr_decode_buf != NULL) {
+                       free(pdu->xdr_decode_buf);
+               }
                pdu->xdr_decode_buf = malloc(pdu->xdr_decode_bufsize);
                if (pdu->xdr_decode_buf == NULL) {
                        rpc_set_error(rpc, "xdr_replymsg failed in portmap_getport_reply");