[omniORB] Getting segmentation fault when I delete an array of structs

Luke Deller ldeller at iress.com.au
Tue Jun 5 11:14:54 BST 2007


W T Meyer wrote:
...
>   CoRCC::slotInfo* tempList = new CoRCC::slotInfo[24];
>   status = rccref[rccHandle]->scanCrate((CoRCC::crateInfo_var)tempList);
...

The expression "(CoRCC::crateInfo_var)tempList" is not what you want.  It will construct a temporary crateInfo_var instance which will claim ownership of tempList.  When this temporary instance is destroyed (right after that line of code) then the crateInfo_var destructor will delete tempList.

>   delete [] tempList;

This line will delete tempList for the second time, which is why you notice a segmentation fault here.

Try removing the type cast.  If you want to use a _var type, then you can declare tempList as that type.

Regards,
Luke.
**********************************************************************************************
Important Note
This email (including any attachments) contains information which is confidential and may be subject to legal privilege.  If you are not the intended recipient you must not use, distribute or copy this email.  If you have received this email in error please notify the
sender immediately and delete this email. Any views expressed in this email are not necessarily the views of IRESS Market Technology Limited.

It is the duty of the recipient to virus scan and otherwise test the information provided before loading onto any computer system.
IRESS Market Technology Limited does not warrant that the information is free of a virus or any other defect or error.
**********************************************************************************************



More information about the omniORB-list mailing list