[asterisk-commits] res smdi: Clean up memory leak (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 24 12:19:31 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6289 )

Change subject: res_smdi: Clean up memory leak
......................................................................

res_smdi: Clean up memory leak

Change-Id: I1e33290929e1aa7c5b9cb513f8254f2884974de8
---
M res/res_smdi.c
1 file changed, 4 insertions(+), 6 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/res/res_smdi.c b/res/res_smdi.c
index f4804c7..9a40227 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -610,12 +610,11 @@
 
 			ast_debug(1, "Read a 'D' ... it's an MD message.\n");
 
-			if (!(md_msg = ast_calloc(1, sizeof(*md_msg)))) {
+			md_msg = ao2_alloc(sizeof(*md_msg), NULL);
+			if (!md_msg) {
 				ao2_ref(iface, -1);
 				return NULL;
 			}
-
-			md_msg = ao2_alloc(sizeof(*md_msg), NULL);
 
 			/* read the message desk number */
 			for (i = 0; i < sizeof(md_msg->mesg_desk_num) - 1; i++) {
@@ -712,12 +711,11 @@
 
 			ast_debug(1, "Read a 'W', it's an MWI message. (No more debug coming for MWI messages)\n");
 
-			if (!(mwi_msg = ast_calloc(1, sizeof(*mwi_msg)))) {
+			mwi_msg = ao2_alloc(sizeof(*mwi_msg), NULL);
+			if (!mwi_msg) {
 				ao2_ref(iface, -1);
 				return NULL;
 			}
-
-			mwi_msg = ao2_alloc(sizeof(*mwi_msg), NULL);
 
 			/* discard the 'I' (from 'MWI') */
 			fgetc(iface->file);

-- 
To view, visit https://gerrit.asterisk.org/6289
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I1e33290929e1aa7c5b9cb513f8254f2884974de8
Gerrit-Change-Number: 6289
Gerrit-PatchSet: 2
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170824/80cc6aa8/attachment.html>


More information about the asterisk-commits mailing list