List Info

Thread: Memory leak on outgoing call




Memory leak on outgoing call
user name
2008-04-18 11:37:31
Hi all,

I found a little memory leak on outgoing mail: when in 
linphone_payload_is_supported the payload is cloned and then
add it to 
profile. So, the function that add the payload to profile in
oRTP is

void rtp_profile_set_payload(RtpProfile *prof, int idx,
PayloadType *pt){
    if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
        ortp_error("Bad index %i",idx);
        return;
    }
    prof->payload[idx]=pt;
}

That function doesn't care if prof->payload[idx] is yet
fill and the 
flags is PAYLOAD_TYPE_ALLOCATED. When we consider the
incoming call the 
remote profile is empty and the calls to
rtp_profile_set_payload() don't 
generate any memory leak.

I'm proposing to fix it in oRTP by
void rtp_profile_set_payload(RtpProfile *prof, int idx,
PayloadType *pt){
    PayloadType *payload;
    if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
        ortp_error("Bad index %i",idx);
        return;
    }
    payload=rtp_profile_get_payload(prof,idx);
    if (payload!=NULL && (payload->flags &
PAYLOAD_TYPE_ALLOCATED))
        payload_type_destroy(payload);
    prof->payload[idx]=pt;
}


Any comments?

Regards

--Michele


_______________________________________________
Linphone-developers mailing list
Linphone-developersnongnu.org
http://lists.nongnu.org/mailman/listinfo/linphone-de
velopers

Re: Memory leak on outgoing call
user name
2008-04-21 07:14:48
damico ha scritto:
> Hi all,
>
> I found a little memory leak on outgoing mail: when in

> linphone_payload_is_supported the payload is cloned and
then add it to 
> profile. So, the function that add the payload to
profile in oRTP is
>
> void rtp_profile_set_payload(RtpProfile *prof, int idx,
PayloadType *pt){
>    if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
>        ortp_error("Bad index %i",idx);
>        return;
>    }
>    prof->payload[idx]=pt;
> }
>
> That function doesn't care if prof->payload[idx] is
yet fill and the 
> flags is PAYLOAD_TYPE_ALLOCATED. When we consider the
incoming call 
> the remote profile is empty and the calls to
rtp_profile_set_payload() 
> don't generate any memory leak.
>
> I'm proposing to fix it in oRTP by
> void rtp_profile_set_payload(RtpProfile *prof, int idx,
PayloadType *pt){
>    PayloadType *payload;
>    if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
>        ortp_error("Bad index %i",idx);
>        return;
>    }
>    payload=rtp_profile_get_payload(prof,idx);
>    if (payload!=NULL && (payload->flags
& PAYLOAD_TYPE_ALLOCATED))
>        payload_type_destroy(payload);
>    prof->payload[idx]=pt;
> }
>
>
> Any comments?
>
> Regards
>
> --Michele
>
>
> _______________________________________________
> Linphone-developers mailing list
> Linphone-developersnongnu.org
> http://lists.nongnu.org/mailman/listinfo/linphone-de
velopers
Sorry,

my analysis is wrong!!
I don't know really what is wrong but I found some
regression either 
when configurations is saved and at the second call because
the payload 
is removed from from the configuration.

I will check better by dmalloc if the memory leak still
exist.

Regards

--Michele


_______________________________________________
Linphone-developers mailing list
Linphone-developersnongnu.org
http://lists.nongnu.org/mailman/listinfo/linphone-de
velopers

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )