From 232351d5ce83915dc5ca2f6dc1614df033f5a0c5 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Fri, 18 Apr 2008 13:54:08 +0000 Subject: [PATCH] various memory leak fixes --- mbuni/mmlib/mms_uaprof.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/mbuni/mmlib/mms_uaprof.c b/mbuni/mmlib/mms_uaprof.c index 266f536..a9d1fd8 100644 --- a/mbuni/mmlib/mms_uaprof.c +++ b/mbuni/mmlib/mms_uaprof.c @@ -654,7 +654,6 @@ static void replace_body(MIMEEntity *msg, Octstr *newbody, List *params_h, List *h = mime_entity_headers(msg); mime_entity_set_body(msg, newbody); /* Replace the body. */ - octstr_destroy(newbody); if ((part_name = http_header_value(params_h, octstr_imm("name"))) != NULL) { Octstr *tmp = mknewname(part_name, file_ext); @@ -675,7 +674,7 @@ static void replace_body(MIMEEntity *msg, Octstr *newbody, List *params_h, } mime_replace_headers(msg,h); http_destroy_headers(h); - if (new_partname) octstr_destroy(new_partname); + octstr_destroy(new_partname); } /* Modify the message based on the user agent profile data. Return 1 if was supported, 0 @@ -755,7 +754,7 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof) replace_ctype(h, "multipart/mixed", params_h); } - if (startp) octstr_destroy(startp); + octstr_destroy(startp); supported = 1; goto done; @@ -779,7 +778,7 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof) if (charset == NULL || octstr_str_compare(charset, "unknown") == 0) { - if (charset) octstr_destroy(charset); + octstr_destroy(charset); charset = octstr_imm(DEFAULT_CHARSET); } @@ -812,8 +811,9 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof) octstr_destroy(ct); mime_entity_set_body(msg,s); /* replace with new body. */ + octstr_destroy(s); break; /* We succeeded in converting it so we shd go away. */ - } else + } else octstr_destroy(s); } @@ -965,6 +965,7 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof) replace_body(msg, s, params_h, cformats[oindex].content_type, cformats[oindex].file_ext,0); + octstr_destroy(s); supported = 1; goto done2; /* we are done, don't even change headers. */ } else /* failed to convert, hence unsupported. */ @@ -978,12 +979,10 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof) remove_object(msg, content_type); if (h) - http_destroy_headers(h); - - if (content_type) - octstr_destroy(content_type); - if (params) - octstr_destroy(params); + http_destroy_headers(h); + + octstr_destroy(content_type); + octstr_destroy(params); if (params_h) http_destroy_headers(params_h); if (tmpf[0]) @@ -991,9 +990,8 @@ static int modify_msg(MIMEEntity *msg, MmsUaProfile *prof) if (tmpf2[0]) unlink(tmpf2); - - if (cmd) - octstr_destroy(cmd); + + octstr_destroy(cmd); return supported; } @@ -1305,11 +1303,12 @@ static int format_special(MIMEEntity *m, if (n < 0 || o != 0) goto done; /* Error -- finish up. */ - if ((s = octstr_read_file(tmpf)) != NULL) + if ((s = octstr_read_file(tmpf)) != NULL) { replace_body(m, s, params_h, cformats[ipref].content_type, cformats[ipref].file_ext,1); - else + octstr_destroy(s); + } else goto done; } else if (type == TTEXT) {/* change to default charset. */