[OpenSIPS-Devel] [ opensips-Bugs-3538551 ] The source code may be bug

SourceForge.net noreply at sourceforge.net
Sat Jul 7 08:51:45 CEST 2012


Bugs item #3538551, was opened at 2012-06-27 20:52
Message generated for change (Comment added) made by bogdan_iancu
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=3538551&group_id=232389

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: 1.8.x
>Status: Closed
Resolution: Invalid
Priority: 2
Private: No
Submitted By: luodaidong (luodaidong)
Assigned to: Bogdan-Andrei Iancu (bogdan_iancu)
Summary: The source code may be bug

Initial Comment:
In the modules tm, The t_fwd.c has a function whose name is pre_print_uac_request;
I don't understand the following source code, this may has memory leak, and the source code  is bad.
if (t->on_branch) {
		/* need to pkg_malloc the dst_uri */
		if ( request->dst_uri.s && request->dst_uri.len>0 ) {
			if ( (p=pkg_malloc(request->dst_uri.len))==0 ) {
				LM_ERR("no more pkg mem\n");
				ser_error=E_OUT_OF_MEM;
				goto error;
			}
			memcpy( p, request->dst_uri.s, request->dst_uri.len);
			request->dst_uri.s = p;
		}
		/* need to pkg_malloc the new_uri */
		if ( (p=pkg_malloc(request->new_uri.len))==0 ) {
			LM_ERR("no more pkg mem\n");
			ser_error=E_OUT_OF_MEM;
			goto error;
		}
		memcpy( p, request->new_uri.s, request->new_uri.len);
		request->new_uri.s = p;




----------------------------------------------------------------------

>Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2012-07-06 23:51

Message:
the "p" buffer is attached to the sip message (request) - everything
attached to the message is freed when the entire message is freed.

----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2012-07-06 22:00

Message:
request->dst_uri.s = p;

request->dst_uri.s no need free ?why?

----------------------------------------------------------------------

Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2012-07-06 09:34

Message:
I double checked the code and I see no leak...Could you point to a case /
scenario where  a leak may happen ?

Thanks and regards,
Bogdan

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=3538551&group_id=232389



More information about the Devel mailing list