[reSIProcate] fault during shutdown in InviteSessionCreator.cxx

Justin Matthews justin.matthews at ivr.com
Mon Jan 17 16:39:12 CST 2005


My mistake, thanks for the correction.  I never delete a null pointer
because I never access a pointer in general without checking if it is null
first.  One other thing to note is that setting pointers to null after
deletion can be helpful in debugging.  This is the same as initializing
pointers to null upon instantiation.  If they are de-referenced you get a
null pointer exception instead of accessing some random memory location,
which can be extremely difficult to find. In this case there is no other
code in the destructor, but this suggestion applies to a more general
defensive coding style.

Thanks,

-Justin

-----Original Message-----
From: derek [mailto:derek at xten.com] 
Sent: Monday, January 17, 2005 1:48 PM
To: 'Justin Matthews'; 'Scott Godin'; resiprocate-devel at list.sipfoundry.org
Subject: RE: [reSIProcate] fault during shutdown in InviteSessionCreator.cxx

delete 0; //is a legal c++ command which doesn't do anything bad.

-----Original Message-----
From: resiprocate-devel-bounces at list.sipfoundry.org
[mailto:resiprocate-devel-bounces at list.sipfoundry.org] On Behalf Of Justin
Matthews
Sent: Monday, January 17, 2005 1:40 PM
To: 'Scott Godin'; resiprocate-devel at list.sipfoundry.org
Subject: RE: [reSIProcate] fault during shutdown in InviteSessionCreator.cxx

This will still fail because the destructor will try to delete a null
pointer in the scenario I described.  A check for null is required before
deleting.  Thanks.

Justin

-----Original Message-----
From: Scott Godin [mailto:slgodin at icescape.com] 
Sent: Monday, January 17, 2005 6:10 AM
To: 'justin.matthews at ivr.com'; resiprocate-devel at list.sipfoundry.org
Subject: RE: [reSIProcate] fault during shutdown in InviteSessionCreator.cxx

I just commited a fix - thanks.

Scott

-----Original Message-----
From: justin.matthews at ivr.com [mailto:justin.matthews at ivr.com] 
Sent: Friday, January 14, 2005 7:58 PM
To: resiprocate-devel at list.sipfoundry.org
Subject: [reSIProcate] fault during shutdown in InviteSessionCreator.cxx

Hello,	
	Dum will crash when calling shutdown if no offer has been created
for an initial dialog set.  This was tested by sending an INVITE request to
nowhere and then immediately shutting down the stack.  Could someone please
update svn?  
	The crash occurs in the destructor:

InviteSessionCreator::~InviteSessionCreator()
{
	delete mInitialOffer;
}

I fixed this by initializing mInitialOffer to NULL on construction and
adding the following on destruction:
--------------
InviteSessionCreator::InviteSessionCreator(DialogUsageManager& dum, 
                                           const NameAddr& target, 
                                           const NameAddr& from,
                                           const SdpContents* initial, 
                                           ServerSubscriptionHandle
serverSub)
   : BaseCreator(dum),
     mState(Initialized),
     mServerSub(serverSub),
     mInitialOffer(NULL)
{
---------------------
InviteSessionCreator::~InviteSessionCreator()
{	
    if( NULL != mInitialOffer )
    {
        delete mInitialOffer;
        mInitialOffer = NULL;
    }
}
----------------

Thanks,

Justin Matthews

_______________________________________________
resiprocate-devel mailing list
resiprocate-devel at list.sipfoundry.org
https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel

_______________________________________________
resiprocate-devel mailing list
resiprocate-devel at list.sipfoundry.org
https://list.sipfoundry.org/mailman/listinfo/resiprocate-devel






More information about the resiprocate-devel mailing list