aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2022-03-20 12:36:06 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2022-03-20 12:36:06 +0000
commit920edd39c12de0e69e54aa0bcde81e6e8d814c22 (patch)
tree5dfb07730b63c34818c5c4f119773e60b5cb7bf9 /contrib
parent89960ca4a4909451f83519cb5c16047246d2ae9e (diff)
downloadrspamd-920edd39c12de0e69e54aa0bcde81e6e8d814c22.tar.gz
rspamd-920edd39c12de0e69e54aa0bcde81e6e8d814c22.zip
[Minor] Plug memory leak when rescheduling requests over TCP
Diffstat (limited to 'contrib')
-rw-r--r--contrib/librdns/resolver.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c
index c12180ec1..cb9824ed4 100644
--- a/contrib/librdns/resolver.c
+++ b/contrib/librdns/resolver.c
@@ -554,11 +554,12 @@ rdns_process_udp_read (int fd, struct rdns_io_channel *ioc)
if (!(rep->flags & RDNS_TRUNCATED)) {
req->state = RDNS_REQUEST_REPLIED;
req->func(rep, req->arg);
+ /* This will free reply as well */
REF_RELEASE (req);
}
else {
- rdns_debug("truncated UDP reply for %s", req->requested_names[0].name);
if (req->io->srv->tcp_io_cnt > 0) {
+ rdns_debug("truncated UDP reply for %s; schedule over TCP", req->requested_names[0].name);
/* Reschedule via TCP */
if (!rdns_reschedule_req_over_tcp (req, req->io->srv)) {
/* Use truncated reply as we have no other options */
@@ -566,6 +567,18 @@ rdns_process_udp_read (int fd, struct rdns_io_channel *ioc)
req->func(rep, req->arg);
REF_RELEASE (req);
}
+ else {
+ /* Remove and free the truncated reply, as we have rescheduled the reply */
+ req->reply = NULL;
+ rdns_reply_free(rep);
+ }
+ }
+ else {
+ /* No TCP channels available */
+ req->state = RDNS_REQUEST_REPLIED;
+ req->func(rep, req->arg);
+ /* This will free reply as well */
+ REF_RELEASE (req);
}
}
}