[Devel] Need some assistance on msg->new_uri manipulation.
Eliot Gable
egable at broadvox.net
Fri Jan 19 17:59:49 CET 2007
In my module code, I have this block of code, copied mostly from
textops.c subst_uri_f:
if(msg->new_uri.s) {
len = msg->new_uri.len;
tmp = msg->new_uri.s;
} else {
tmp = msg->first_line.u.request.uri.s;
len = msg->first_line.u.request.uri.len;
}
c = tmp[len];
tmp[len] = 0;
result = subst_str(tmp, msg, se, 0); /* pkg malloc'ed result */
tmp[len] = c;
if(result) {
/* if(msg->new_uri.s) {
pkg_free(msg->new_uri.s);
msg->new_uri.s = NULL;
msg->new_uri.len = 0;
} */
msg->new_uri=*result;
msg->parsed_uri_ok = 0;
pkg_free(result);
}
subst_expr_free(se);
If I leave the pkg_free(msg->new_uri.s) commented out, things seem to
work. But in textops.c, it frees new_uri.s if it is allocated. If I free
it in my code, I get an abort() because of a double free here in
parser/msg_parser.c:
/*only the content*/
void free_sip_msg(struct sip_msg* msg)
{
-->> if (msg->new_uri.s) { pkg_free(msg->new_uri.s);
msg->new_uri.len=0; msg->n
if (msg->dst_uri.s) { pkg_free(msg->dst_uri.s); msg->dst_uri.len=0;
msg->d
if (msg->path_vec.s) { pkg_free(msg->path_vec.s);
msg->path_vec.len=0; msg
if (msg->headers) free_hdr_field_lst(msg->headers);
if (msg->add_rm) free_lump_list(msg->add_rm);
if (msg->body_lumps) free_lump_list(msg->body_lumps);
if (msg->reply_lump) free_reply_lump(msg->reply_lump);
/* don't free anymore -- now a pointer to a static buffer */
# ifdef DYN_BUF
pkg_free(msg->buf);
msg->buf = NULL;
# endif
}
Why is it that msg->new_uri.s still points to the memory location that I
freed in my code when immediately after that free I am setting new_uri.s
to a new memory location?:
msg->new_uri=*result;
Is the SIP message cloned somewhere before it is passed to my module? If
so, should I be freeing new_uri.s in my module or will it get taken care
of elsewhere in the code?
Eliot Gable
Operations Engineer
CCNA, CWNA, CWSP, Network+, Security+
Broadvox, LLC
1228 Euclid Avenue
Suite 390
Cleveland, OH 44115-1800
216-373-4808
More information about the Devel
mailing list