various memory leak fixes
This commit is contained in:
parent
ee5c86878d
commit
e78739a3a1
|
@ -1,3 +1,5 @@
|
|||
2008-04-18 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Various memory leak fixes (thanks to Monachin Eric @ Skycore)
|
||||
2008-04-11 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Added no-sender-address config to mmsc section: Allows you to
|
||||
* suppress SenderAddress SOAP/XML tag
|
||||
|
|
|
@ -229,11 +229,12 @@ void mms_cfg_destroy(mCfg *cfg)
|
|||
for (i = 0, l = dict_keys(cfg->grps), n = gwlist_len(l); i < n; i++) {
|
||||
Octstr *grpname = gwlist_get(l, i);
|
||||
void *val = dict_get(cfg->grps, grpname);
|
||||
if (is_multigroup(grpname)) {
|
||||
if (is_multigroup(grpname)) { /* item is a list. */
|
||||
List *gl = val;
|
||||
int j, m = gwlist_len(gl);
|
||||
for (j = 0; j < m; j++)
|
||||
mGrp_destroy(gwlist_get(gl, j));
|
||||
gwlist_destroy(gl, NULL);
|
||||
} else
|
||||
mGrp_destroy(val);
|
||||
}
|
||||
|
|
|
@ -673,7 +673,7 @@ static Octstr *headers_to_soapxml(List *hdrs, MM7Version_t *ver)
|
|||
int mm7_soapmsg_to_httpmsg(MSoapMsg_t *m, MM7Version_t *ver, List **hdrs, Octstr **body)
|
||||
{
|
||||
MIMEEntity *mime;
|
||||
Octstr *ctype, *s;
|
||||
Octstr *ctype = NULL, *s;
|
||||
List *headers;
|
||||
|
||||
mime = mime_entity_create();
|
||||
|
@ -749,6 +749,7 @@ int mm7_soapmsg_to_httpmsg(MSoapMsg_t *m, MM7Version_t *ver, List **hdrs, Octstr
|
|||
debug("mms2soap", 0, "SOAP MSG is: %s", octstr_get_cstr(*body));
|
||||
|
||||
mime_entity_destroy(mime);
|
||||
octstr_destroy(ctype);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1006,7 +1006,7 @@ static int encode_msgheaders(Octstr *os, List *hdrs)
|
|||
/* Does basic fixups on a message. */
|
||||
static int fixup_msg(MmsMsg *m, Octstr *from)
|
||||
{
|
||||
Octstr *ver;
|
||||
Octstr *ver = NULL;
|
||||
Octstr *s = NULL;
|
||||
if (!m)
|
||||
return -1;
|
||||
|
@ -1027,7 +1027,7 @@ static int fixup_msg(MmsMsg *m, Octstr *from)
|
|||
/* Check for from. */
|
||||
if (from && (s = http_header_value(m->headers, octstr_imm("From"))) == NULL)
|
||||
http_header_add(m->headers, "From", octstr_get_cstr(from));
|
||||
else if (s)
|
||||
else
|
||||
octstr_destroy(s);
|
||||
|
||||
/* Check for date. */
|
||||
|
@ -1043,8 +1043,8 @@ static int fixup_msg(MmsMsg *m, Octstr *from)
|
|||
if ((s = http_header_value(m->headers, octstr_imm("X-Mms-Transaction-ID"))) == NULL) {
|
||||
if (m->message_type != MMS_MSGTYPE_RETRIEVE_CONF)
|
||||
http_header_add(m->headers, "X-Mms-Transaction-ID", "00001");
|
||||
} else
|
||||
octstr_destroy(s);
|
||||
}
|
||||
#if 0 /* This will be done elsewhere. */
|
||||
/* Check for msgid, put in if missing. */
|
||||
if ((s = http_header_value(m->headers, octstr_imm("Message-ID"))) == NULL)
|
||||
|
@ -1077,6 +1077,7 @@ static int fixup_msg(MmsMsg *m, Octstr *from)
|
|||
http_header_remove_all(m->headers, "Content-Type"); /* Just in case, particularly from mime! */
|
||||
break;
|
||||
}
|
||||
octstr_destroy(ver);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1222,10 +1223,10 @@ int mms_messagetype(MmsMsg *msg)
|
|||
}
|
||||
|
||||
|
||||
static void convert_mime_msg(MIMEEntity *m)
|
||||
static int convert_mime_msg(MIMEEntity *m)
|
||||
{
|
||||
int i, n;
|
||||
Octstr *content_type = NULL, *params;
|
||||
int i, n, res = 0;
|
||||
Octstr *content_type = NULL, *params = NULL;
|
||||
char *s = NULL;
|
||||
List *h = mime_entity_headers(m);
|
||||
|
||||
|
@ -1241,8 +1242,8 @@ static void convert_mime_msg(MIMEEntity *m)
|
|||
else if (octstr_str_compare(content_type,
|
||||
"application/vnd.wap.multipart.mixed") == 0)
|
||||
s = "multipart/mixed";
|
||||
octstr_destroy(content_type);
|
||||
}
|
||||
|
||||
if (s) {
|
||||
Octstr *value;
|
||||
|
||||
|
@ -1260,21 +1261,29 @@ static void convert_mime_msg(MIMEEntity *m)
|
|||
mime_replace_headers(m,h);
|
||||
|
||||
octstr_destroy(value);
|
||||
res = 1;
|
||||
}
|
||||
|
||||
http_destroy_headers(h);
|
||||
octstr_destroy(params);
|
||||
if ((n = mime_entity_num_parts(m)) > 0)
|
||||
for (i = 0; i < n; i++) {
|
||||
MIMEEntity *x = mime_entity_get_part(m, i);
|
||||
convert_mime_msg(x);
|
||||
mime_entity_replace_part(m, i, x);
|
||||
int xres = convert_mime_msg(x);
|
||||
if (xres) {
|
||||
mime_entity_replace_part(m, i, x);
|
||||
res = 1;
|
||||
}
|
||||
mime_entity_destroy(x);
|
||||
}
|
||||
octstr_destroy(params);
|
||||
octstr_destroy(content_type);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void unconvert_mime_msg(MIMEEntity *m)
|
||||
static int unconvert_mime_msg(MIMEEntity *m)
|
||||
{
|
||||
int i, n;
|
||||
int i, n, res = 0;
|
||||
Octstr *content_type, *params;
|
||||
char *s = NULL;
|
||||
List *h = mime_entity_headers(m);
|
||||
|
@ -1298,7 +1307,7 @@ static void unconvert_mime_msg(MIMEEntity *m)
|
|||
mime_entity_set_body(m, x);
|
||||
octstr_destroy(x);
|
||||
}
|
||||
octstr_destroy(content_type);
|
||||
res = 1;
|
||||
}
|
||||
|
||||
if (s)
|
||||
|
@ -1306,13 +1315,18 @@ static void unconvert_mime_msg(MIMEEntity *m)
|
|||
mime_replace_headers(m, h);
|
||||
http_destroy_headers(h);
|
||||
octstr_destroy(params);
|
||||
|
||||
octstr_destroy(content_type);
|
||||
if ((n = mime_entity_num_parts(m)) > 0)
|
||||
for (i = 0; i < n; i++) {
|
||||
MIMEEntity *x = mime_entity_get_part(m, i);
|
||||
unconvert_mime_msg(x);
|
||||
mime_entity_replace_part(m, i, x);
|
||||
int xres = unconvert_mime_msg(x);
|
||||
if (xres) {
|
||||
mime_entity_replace_part(m, i, x);
|
||||
res = 1;
|
||||
}
|
||||
mime_entity_destroy(x);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -223,8 +223,6 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho
|
|||
NULL,
|
||||
qf,
|
||||
sizeof (struct qfile_t), NULL);
|
||||
|
||||
e->to = gwlist_create();
|
||||
qfs = e->qfs_data;
|
||||
|
||||
qfs->fd = fd;
|
||||
|
|
|
@ -1054,7 +1054,7 @@ static int format_special(MIMEEntity *m,
|
|||
|
||||
if ((n = mime_entity_num_parts(m)) > 0) {
|
||||
int presindex = -1;
|
||||
Octstr *presbody;
|
||||
Octstr *presbody = NULL;
|
||||
Octstr *start = http_header_value(params_h, octstr_imm("start"));
|
||||
|
||||
for (i = 0; i<n; i++) {/* format sub-parts, find presentation part too */
|
||||
|
@ -1073,9 +1073,9 @@ static int format_special(MIMEEntity *m,
|
|||
presindex = i;
|
||||
|
||||
|
||||
if (ctype) octstr_destroy(ctype);
|
||||
if (charset) octstr_destroy(charset);
|
||||
if (cid) octstr_destroy(cid);
|
||||
octstr_destroy(ctype);
|
||||
octstr_destroy(charset);
|
||||
octstr_destroy(cid);
|
||||
|
||||
format_special(x, trans_smil, txtmsg, htmlmsg, counter);
|
||||
mime_entity_replace_part(m, i, x);
|
||||
|
@ -1084,7 +1084,7 @@ static int format_special(MIMEEntity *m,
|
|||
mime_entity_destroy(x);
|
||||
}
|
||||
|
||||
if (start) octstr_destroy(start);
|
||||
octstr_destroy(start);
|
||||
|
||||
if (trans_smil && presindex >= 0) { /* Reformat. */
|
||||
MIMEEntity *x, *pres;
|
||||
|
@ -1105,7 +1105,7 @@ static int format_special(MIMEEntity *m,
|
|||
Octstr *y, *loc, *cidurl;
|
||||
List *cparamsl;
|
||||
|
||||
if (i == presindex) continue; /* Skip the presentation param. */
|
||||
if (i == presindex) goto loop; /* Skip the presentation param. */
|
||||
|
||||
hx = mime_entity_headers(x);
|
||||
cid = _x_get_content_id(hx);
|
||||
|
@ -1172,15 +1172,17 @@ static int format_special(MIMEEntity *m,
|
|||
mime_entity_replace_part(m, i, x);
|
||||
|
||||
http_destroy_headers(hx);
|
||||
mime_entity_destroy(x);
|
||||
|
||||
if (y) octstr_destroy(y);
|
||||
if (loc) octstr_destroy(loc);
|
||||
if (ctype) octstr_destroy(ctype);
|
||||
if (cidurl) octstr_destroy(cidurl);
|
||||
if (pname) octstr_destroy(pname);
|
||||
octstr_destroy(y);
|
||||
octstr_destroy(loc);
|
||||
octstr_destroy(ctype);
|
||||
octstr_destroy(cidurl);
|
||||
octstr_destroy(pname);
|
||||
|
||||
octstr_destroy(cid);
|
||||
|
||||
loop:
|
||||
mime_entity_destroy(x);
|
||||
}
|
||||
|
||||
pres = mime_entity_get_part(m,presindex);
|
||||
|
@ -1240,6 +1242,7 @@ static int format_special(MIMEEntity *m,
|
|||
mime_entity_replace_part(m, presindex, pres);
|
||||
mime_entity_destroy(pres);
|
||||
|
||||
octstr_destroy(presbody);
|
||||
octstr_destroy(btxt);
|
||||
}
|
||||
goto done;
|
||||
|
@ -1344,12 +1347,12 @@ static int format_special(MIMEEntity *m,
|
|||
mime_replace_headers(m, headers);
|
||||
http_destroy_headers(headers);
|
||||
}
|
||||
if (content_type)
|
||||
octstr_destroy(content_type);
|
||||
|
||||
octstr_destroy(content_type);
|
||||
octstr_destroy(params);
|
||||
if (params_h)
|
||||
http_destroy_headers(params_h);
|
||||
if (cmd)
|
||||
octstr_destroy(cmd);
|
||||
octstr_destroy(cmd);
|
||||
|
||||
if (tmpf[0])
|
||||
unlink(tmpf);
|
||||
|
|
|
@ -1224,6 +1224,7 @@ void strip_boundary_element(List *headers, char *s)
|
|||
if (ctype != value)
|
||||
octstr_destroy(ctype);
|
||||
octstr_destroy(value);
|
||||
octstr_destroy(params);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1154,6 +1154,7 @@ done:
|
|||
octstr_destroy(xfrom);
|
||||
octstr_destroy(subject);
|
||||
octstr_destroy(otransid);
|
||||
octstr_destroy(turl);
|
||||
if (me)
|
||||
mime_entity_destroy(me);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
|
|||
{
|
||||
mCfgGrp *grp = mms_cfg_get_single(cfg, octstr_imm("mbuni"));
|
||||
mCfgGrp *cgrp = mms_cfg_get_single(cfg, octstr_imm("core"));
|
||||
Octstr *gdir, *s, *tmp;
|
||||
Octstr *gdir = NULL, *s, *tmp;
|
||||
int send_port_ssl = 0;
|
||||
List *l;
|
||||
int i, n, xx;
|
||||
|
@ -184,8 +184,8 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
|
|||
m->id = _mms_cfg_getx(x, octstr_imm("id"));
|
||||
if (octstr_len(m->id) < 1)
|
||||
panic(0,"Missing required value `id' in config file!");
|
||||
m->group_id = _mms_cfg_getx(x, octstr_imm("group-id"));
|
||||
if (octstr_len(m->group_id) < 1)
|
||||
m->group_id = mms_cfg_get(x, octstr_imm("group-id"));
|
||||
if (m->group_id == NULL)
|
||||
m->group_id = octstr_duplicate(m->id);
|
||||
|
||||
m->mmsc_url = _mms_cfg_getx(x, octstr_imm("mmsc-url"));
|
||||
|
@ -211,12 +211,12 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
|
|||
#ifdef HAVE_LIBSSL
|
||||
mms_cfg_get_bool(x, octstr_imm("incoming-port-ssl"), &ssl);
|
||||
#endif
|
||||
if ((tmp = _mms_cfg_getx(x, octstr_imm("max-throughput"))) != NULL) {
|
||||
if ((tmp = mms_cfg_get(x, octstr_imm("max-throughput"))) != NULL) {
|
||||
if (octstr_parse_double(&m->throughput, tmp, 0) == -1)
|
||||
m->throughput = 0;
|
||||
octstr_destroy(tmp);
|
||||
info(0, "Set throughput to %.3f for mmsc id <%s>",
|
||||
m->throughput, octstr_get_cstr(m->id));
|
||||
octstr_destroy(tmp);
|
||||
}
|
||||
|
||||
type = _mms_cfg_getx(x, octstr_imm("type"));
|
||||
|
@ -456,6 +456,7 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func)
|
|||
gwlist_append(mms_services, m);
|
||||
}
|
||||
gwlist_destroy(l, NULL);
|
||||
octstr_destroy(gdir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -154,8 +154,8 @@ static void start_push(Octstr *rcpt_to, int isphonenum, MmsEnvelope *e, MmsMsg *
|
|||
static int receive_push_reply(HTTPCaller *caller)
|
||||
{
|
||||
int http_status;
|
||||
List *reply_headers;
|
||||
Octstr *final_url, *reply_body;
|
||||
List *reply_headers = NULL;
|
||||
Octstr *final_url = NULL, *reply_body = NULL;
|
||||
|
||||
MmsEnvelope *env;
|
||||
|
||||
|
@ -211,14 +211,14 @@ static int receive_push_reply(HTTPCaller *caller)
|
|||
|
||||
/* Fall through. */
|
||||
push_failed:
|
||||
octstr_destroy(final_url);
|
||||
octstr_destroy(reply_body);
|
||||
http_destroy_headers(reply_headers);
|
||||
|
||||
env = update_env_failed(env);
|
||||
push_free_env:
|
||||
if (env && env != &edummy)
|
||||
settings->qfs->mms_queue_free_env(env);
|
||||
|
||||
octstr_destroy(final_url);
|
||||
octstr_destroy(reply_body);
|
||||
http_destroy_headers(reply_headers);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue