diff options
author | Hajime Fujita <crisp.fujita@nifty.com> | 2016-11-06 12:54:25 -0600 |
---|---|---|
committer | Tanu Kaskinen <tanuk@iki.fi> | 2017-01-19 03:10:19 +0200 |
commit | ab7b7ee24946058aa8185d1b400d63619676baab (patch) | |
tree | 041c44059f6eeee767d1612001a28a99929db1d6 | |
parent | d7721032ea3aee1a7845f7853d7978255c367296 (diff) |
raop: Fix memory leaks
This patch fixes several memory leaks, and thereby fixes Issue #35.
(https://github.com/hfujita/pulseaudio-raop2/issues/35)
-rw-r--r-- | src/modules/raop/raop-client.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/modules/raop/raop-client.c b/src/modules/raop/raop-client.c index f71ad9d3a..d695ce9e1 100644 --- a/src/modules/raop/raop-client.c +++ b/src/modules/raop/raop-client.c @@ -537,6 +537,7 @@ static ssize_t resend_udp_audio_packets(pa_raop_client *c, uint16_t seq, uint16_ return total; } +/* Caller has to free the allocated memory region for packet */ static size_t build_udp_sync_packet(pa_raop_client *c, uint32_t stamp, uint32_t **packet) { const size_t size = sizeof(udp_sync_header) + 12; const uint32_t delay = 88200; @@ -570,8 +571,10 @@ static ssize_t send_udp_sync_packet(pa_raop_client *c, uint32_t stamp) { size_t size = 0; size = build_udp_sync_packet(c, stamp, &packet); - if (packet != NULL && size > 0) + if (packet != NULL && size > 0) { written = pa_loop_write(c->udp_cfd, packet, size, NULL); + pa_xfree(packet); + } return written; } @@ -606,6 +609,7 @@ static size_t handle_udp_control_packet(pa_raop_client *c, const uint8_t packet[ return written; } +/* Caller has to free the allocated memory region for packet */ static size_t build_udp_timing_packet(pa_raop_client *c, const uint32_t data[6], uint64_t received, uint32_t **packet) { const size_t size = sizeof(udp_timing_header) + 24; uint32_t *buffer = NULL; @@ -638,8 +642,10 @@ static ssize_t send_udp_timing_packet(pa_raop_client *c, const uint32_t data[6], size_t size = 0; size = build_udp_timing_packet(c, data, received, &packet); - if (packet != NULL && size > 0) + if (packet != NULL && size > 0) { written = pa_loop_write(c->udp_tfd, packet, size, NULL); + pa_xfree(packet); + } return written; } @@ -1366,7 +1372,7 @@ pa_raop_client* pa_raop_client_new(pa_core *core, const char *host, pa_raop_prot c = pa_xnew0(pa_raop_client, 1); c->core = core; - c->host = pa_xstrdup(a.path_or_host); + c->host = a.path_or_host; /* Will eventually be freed on destruction of c */ if (a.port > 0) c->port = a.port; else |