[Asterisk-code-review] res smdi: Clean up memory leak (asterisk[master])

Sean Bright asteriskteam at digium.com
Thu Aug 24 08:38:04 CDT 2017


Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/6292


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(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/92/6292/1

diff --git a/res/res_smdi.c b/res/res_smdi.c
index e2e5b17..bf69d68 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -608,12 +608,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 (!ms_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++) {
@@ -710,12 +709,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/6292
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1e33290929e1aa7c5b9cb513f8254f2884974de8
Gerrit-Change-Number: 6292
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170824/32fba643/attachment-0001.html>


More information about the asterisk-code-review mailing list