fixing memory leak issue for audit request

This commit is contained in:
Kapil Gupta 2012-08-22 09:04:14 -04:00
parent 6c6af2ee59
commit fad4444203
3 changed files with 12 additions and 8 deletions

View File

@ -1857,7 +1857,7 @@ switch_status_t handle_mg_audit_cmd( megaco_profile_t* mg_profile, MgMgcoCommand
adtRep->u.other.audit.parms[numOfParms - 1]->type.pres = PRSNT_NODEF; adtRep->u.other.audit.parms[numOfParms - 1]->type.pres = PRSNT_NODEF;
adtRep->u.other.audit.parms[numOfParms - 1]->type.val = MGT_MEDIADESC; adtRep->u.other.audit.parms[numOfParms - 1]->type.val = MGT_MEDIADESC;
media = get_default_media_desc(mg_profile, termId); media = get_default_media_desc(mg_profile, termId, &reply.u.mgCmdRsp[0]->memCp);
if(!media){ if(!media){
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }

View File

@ -186,7 +186,7 @@ switch_status_t handle_mg_subtract_cmd(megaco_profile_t* mg_profile, MgMgcoComma
switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *cmd); switch_status_t handle_mg_modify_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *cmd);
switch_status_t mg_stack_free_mem(void* msg); switch_status_t mg_stack_free_mem(void* msg);
switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize ); switch_status_t mg_stack_alloc_mem( Ptr* _memPtr, Size _memSize );
MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTermId* termId); MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTermId* termId, CmMemListCp *memCp);
switch_status_t handle_media_audit( SuId suId, MgMgcoCommand *auditReq); switch_status_t handle_media_audit( SuId suId, MgMgcoCommand *auditReq);
switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req); switch_status_t mg_send_add_rsp(SuId suId, MgMgcoCommand *req);
S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, char* term_str, int term_len, CmMemListCp *memCp); S16 mg_fill_mgco_termid ( MgMgcoTermId *termId, char* term_str, int term_len, CmMemListCp *memCp);

View File

@ -1478,13 +1478,14 @@ void mg_util_set_term_string ( MgStr *errTxt, MgMgcoTermId *termId)
"info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val); "info, error-text is: %s\n", __PRETTY_FUNCTION__,errTxt->val);
} }
/*****************************************************************************************************************************/ /*****************************************************************************************************************************/
MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTermId* termId) MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTermId* termId, CmMemListCp *memCp)
{ {
MgMgcoMediaDesc *media = NULL; MgMgcoMediaDesc *media = NULL;
MgMgcoMediaPar *mediaPar = NULL; MgMgcoMediaPar *mediaPar = NULL;
MgMgcoTermStateParm *trmStPar = NULL; MgMgcoTermStateParm *trmStPar = NULL;
S16 ret = ROK;
mg_stack_alloc_mem((Ptr)&media, sizeof(MgMgcoMediaDesc)); MG_GETMEM(media, sizeof(MgMgcoMediaDesc) , memCp, ret);
if (!media) { if (!media) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n");
@ -1492,14 +1493,15 @@ MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTerm
} }
media->num.pres = PRSNT_NODEF; media->num.pres = PRSNT_NODEF;
media->num.val = 1; media->num.val = 1;
mg_stack_alloc_mem((Ptr)&mediaPar, sizeof(MgMgcoMediaPar));
MG_GETMEM(mediaPar, sizeof(MgMgcoMediaPar) , memCp, ret);
if (!mediaPar) { if (!mediaPar) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n");
mg_stack_free_mem(media); mg_stack_free_mem(media);
return NULL; return NULL;
} }
mg_stack_alloc_mem((Ptr)&media->parms, sizeof(MgMgcoMediaPar *)); MG_GETMEM(media->parms, sizeof(MgMgcoMediaPar*) , memCp, ret);
if (!media->parms) { if (!media->parms) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n");
@ -1511,7 +1513,8 @@ MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTerm
mediaPar->type.val = MGT_MEDIAPAR_TERMST; mediaPar->type.val = MGT_MEDIAPAR_TERMST;
mediaPar->u.tstate.numComp.pres = PRSNT_NODEF; mediaPar->u.tstate.numComp.pres = PRSNT_NODEF;
mediaPar->u.tstate.numComp.val = 1; mediaPar->u.tstate.numComp.val = 1;
mg_stack_alloc_mem((Ptr)&trmStPar, sizeof(MgMgcoTermStateParm));
MG_GETMEM(trmStPar, sizeof(MgMgcoTermStateParm) , memCp, ret);
if (!trmStPar) { if (!trmStPar) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n");
@ -1520,7 +1523,8 @@ MgMgcoMediaDesc* get_default_media_desc(megaco_profile_t* mg_profile, MgMgcoTerm
mg_stack_free_mem((void*)media); mg_stack_free_mem((void*)media);
return NULL; return NULL;
} }
mg_stack_alloc_mem((Ptr)&mediaPar->u.tstate.trmStPar, sizeof(MgMgcoTermStateParm *)); MG_GETMEM(mediaPar->u.tstate.trmStPar, sizeof(MgMgcoTermStateParm *) , memCp, ret);
if (!mediaPar->u.tstate.trmStPar) { if (!mediaPar->u.tstate.trmStPar) {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n"); switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_ERROR, "failed, memory alloc\n");
mg_stack_free_mem((void*)trmStPar); mg_stack_free_mem((void*)trmStPar);