From: Sean Bright Date: Thu, 24 Aug 2017 13:35:45 +0000 (-0400) Subject: res_smdi: Clean up memory leak X-Git-Tag: 13.18.0-rc1~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d251a961ace674218488e6a906a874d2ef2212c1;p=thirdparty%2Fasterisk.git res_smdi: Clean up memory leak Change-Id: I1e33290929e1aa7c5b9cb513f8254f2884974de8 --- diff --git a/res/res_smdi.c b/res/res_smdi.c index f4804c7cb2..9a40227f2d 100644 --- a/res/res_smdi.c +++ b/res/res_smdi.c @@ -610,13 +610,12 @@ static void *smdi_read(void *iface_p) 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++) { md_msg->mesg_desk_num[i] = fgetc(iface->file); @@ -712,13 +711,12 @@ static void *smdi_read(void *iface_p) 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);