Skip to content

Commit cb0cf40

Browse files
authored
Merge pull request #167 from madhuthorat/cid__rpc_taddr2uaddr_af
Free 'ret' when returning NULL in __rpc_taddr2uaddr_af()
2 parents 57b2605 + f8b5fa5 commit cb0cf40

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/rpc_generic.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,16 @@ __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf)
788788

789789
switch (af) {
790790
case AF_INET:
791-
if (nbuf->len < sizeof(*sin))
791+
if (nbuf->len < sizeof(*sin)) {
792+
mem_free(ret, RETURN_SIZE);
792793
return NULL;
794+
}
793795
sin = nbuf->buf;
794796
if (inet_ntop(af, &sin->sin_addr, namebuf, sizeof(namebuf))
795-
== NULL)
797+
== NULL) {
798+
mem_free(ret, RETURN_SIZE);
796799
return NULL;
800+
}
797801
port = ntohs(sin->sin_port);
798802
if (sprintf
799803
(ret, "%s.%u.%u", namebuf, ((u_int32_t) port) >> 8,
@@ -804,8 +808,10 @@ __rpc_taddr2uaddr_af(int af, const struct netbuf *nbuf)
804808
break;
805809
#ifdef INET6
806810
case AF_INET6:
807-
if (nbuf->len < sizeof(*sin6))
811+
if (nbuf->len < sizeof(*sin6)) {
812+
mem_free(ret, RETURN_SIZE);
808813
return NULL;
814+
}
809815
sin6 = nbuf->buf;
810816
if (inet_ntop(af, &sin6->sin6_addr, namebuf6, sizeof(namebuf6))
811817
== NULL) {

0 commit comments

Comments
 (0)