Skip to content

Commit

Permalink
udp: fix leaks on EP destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Oct 7, 2024
1 parent d59de52 commit 6d59cbc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/sp/transport/udp/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "core/aio.h"
#include "core/defs.h"
#include "core/idhash.h"
#include "core/message.h"
#include "core/nng_impl.h"
#include "core/options.h"
#include "core/platform.h"
Expand Down Expand Up @@ -319,6 +320,7 @@ udp_pipe_destroy(udp_pipe *p)
nni_lmq_get(&p->rx_mq, &m);
nni_msg_free(m);
}
nni_lmq_fini(&p->rx_mq);
NNI_ASSERT(nni_list_empty(&p->rx_aios));

NNI_FREE_STRUCT(p);
Expand Down Expand Up @@ -1119,6 +1121,12 @@ udp_ep_rele(udp_ep *ep)
nni_aio_fini(&ep->resaio);
nni_aio_fini(&ep->tx_aio);
nni_aio_fini(&ep->rx_aio);

for (int i = 0; i < ep->tx_ring.size; i++) {
nni_msg_free(ep->tx_ring.descs[i].payload);
ep->tx_ring.descs[i].payload = NULL;
}
nni_msg_free(ep->rx_payload); // safe even if msg is null
nni_id_map_fini(&ep->pipes);
NNI_FREE_STRUCTS(ep->tx_ring.descs, ep->tx_ring.size);
NNI_FREE_STRUCT(ep);
Expand Down Expand Up @@ -1276,7 +1284,7 @@ udp_ep_init(udp_ep **epp, nng_url *url, nni_sock *sock)
ep->af = NNG_AF_INET;
} else if (strcmp(url->u_scheme, "udp6") == 0) {
ep->af = NNG_AF_INET6;
} else {
} else {

Check warning on line 1287 in src/sp/transport/udp/udp.c

View check run for this annotation

Codecov / codecov/patch

src/sp/transport/udp/udp.c#L1287

Added line #L1287 was not covered by tests
NNI_FREE_STRUCT(ep);
return (NNG_EADDRINVAL);
}
Expand Down

0 comments on commit 6d59cbc

Please sign in to comment.