From 6cef51763c6db584744ba15a0a014eabd4e07910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= <rafael.carre@savoirfairelinux.com> Date: Fri, 8 Jul 2011 12:07:45 -0400 Subject: [PATCH] * #6392: fix a memory leak, replace by stack allocation bug found by cppcheck --- sflphone-common/src/sip/sipvoiplink.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 0952ab5fed..0f3c9e181f 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -1446,8 +1446,7 @@ SIPVoIPLink::dtmfSipInfo (SIPCall *call, char code) { int duration; - const int body_len = 1000; - char *dtmf_body; + char dtmf_body[1000]; pj_status_t status; pjsip_tx_data *tdata; pj_str_t methodName, content; @@ -1466,10 +1465,6 @@ SIPVoIPLink::dtmfSipInfo (SIPCall *call, char code) duration = Manager::instance().voipPreferences.getPulseLength(); - dtmf_body = new char[body_len]; - - snprintf (dtmf_body, body_len - 1, "Signal=%c\r\nDuration=%d\r\n", code, duration); - pj_strdup2 (tmp_pool, &methodName, "INFO"); pjsip_method_init_np (&method, &methodName); @@ -1486,6 +1481,8 @@ SIPVoIPLink::dtmfSipInfo (SIPCall *call, char code) pj_strdup2 (tmp_pool, &ctype.subtype, "dtmf-relay"); + snprintf (dtmf_body, sizeof dtmf_body - 1, "Signal=%c\r\nDuration=%d\r\n", code, duration); + /* Create "application/dtmf-relay" message body. */ pj_strdup2 (tmp_pool, &content, dtmf_body); -- GitLab