From 8fb603e5c32d37e0a55e42217dfd978147cac3a2 Mon Sep 17 00:00:00 2001 From: Razvan Crainea Date: Fri, 21 Jun 2019 15:50:31 +0300 Subject: [PATCH] dtmf: prevent freeing json buf too early When both logging and sending the DTMF event further, the json buffer was released/freed _before_ being sent on the network, resulting in a 0-length UDP packet. On the other hand, if only UDP sending was used (without logging), a leak was happening. This commit fixes both issues. --- daemon/dtmf.c | 1 + daemon/log.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/dtmf.c b/daemon/dtmf.c index cfc1d3f60..82fd6c7d7 100644 --- a/daemon/dtmf.c +++ b/daemon/dtmf.c @@ -82,6 +82,7 @@ int dtmf_event(struct media_packet *mp, str *payload, int clockrate) { dtmflog(buf); if (dtmf_log_sock.family) send(dtmf_log_sock.fd, buf->str, buf->len, 0); + g_string_free(buf, TRUE); ret = 1; // END event } diff --git a/daemon/log.c b/daemon/log.c index 56f48ffbe..57ad53bc5 100644 --- a/daemon/log.c +++ b/daemon/log.c @@ -125,7 +125,6 @@ void dtmflog(GString *s) { if (_log_facility_dtmf) { syslog(LOG_INFO | _log_facility_dtmf, "%s", s->str); } - g_string_free(s, TRUE); }