[
http://issues.apache.org/jira/browse/AXISCPP-343?page=comments#action_12330947
]
Unai Uribarri commented on AXISCPP-343:
---------------------------------------
To grow an array, this function allocates a new bigger array and copies raw
memory from the old array to the new memory. This is incorrect since the new
array already contains constructed objects. Overwritting this memory will leak
any resource allocated by the constructor of these objects.
I think that swapping the memory can work. Just replace memcpy and memset by
this code:
char *p1 = (char *)pObj;
char *p2 = (char *)pNew;
size_t i = sizeof(mapItem) * size / 2;
while (i)
{
char c = *p1;
*p1 = *p2;
*p2 = c;
++p1;
++p2;
--i;
}
> SIGSEGV deserializing an array of complex elements
> --------------------------------------------------
>
> Key: AXISCPP-343
> URL: http://issues.apache.org/jira/browse/AXISCPP-343
> Project: Axis-C++
> Type: Bug
> Components: Serialization
> Versions: 1.4 Final
> Environment: RH9
> Reporter: Unai Uribarri
> Assignee: Dushshantha Chandradasa
> Attachments: siaam.wsdl
>
> The function Axis_Create_* (in the following example, the mapItem
> object) in the stubs generated by wsdl2ws java tool generates a SIGSEGV
> when tring to enlarge an array of objects
> mapItem* pNew = new mapItem[nSize];
> memcpy(pNew, pObj, sizeof(mapItem)*nSize/2);
> memset(pObj, 0, sizeof(mapItem)*nSize/2);
> --> delete [] pObj; <-- SIGSEGV
> memset clears the virtual table pointer of the mapItem objects and the delete
> operator crash.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira