[
https://issues.apache.org/jira/browse/XALANC-742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13628136#comment-13628136
]
Michael Chisholm commented on XALANC-742:
-----------------------------------------
Well I figured out the hard way that Xerces' memory manager still has to be set
up when a XalanVector goes out of scope, because XalanVector's dtor needs it to
release memory. So here's a more correct version of the demo app:
#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/Include/XalanVector.hpp>
using namespace xercesc;
using namespace xalanc;
int main(int argc, char* argv[])
{
XMLPlatformUtils::Initialize();
{
XalanVector<int> vec1;
XalanVector<int> vec2(XalanMemMgrs::getDefaultXercesMemMgr(),
5);
vec1 = vec2;
}
XMLPlatformUtils::Terminate();
return 0;
}
I have also fixed it in my own way, basically by making the assignment a no-op
if both vectors are empty:
Index: XalanVector.hpp
===================================================================
--- XalanVector.hpp (revision 1466627)
+++ XalanVector.hpp (working copy)
@@ -809,6 +809,9 @@
if (&theRHS != this)
{
+ if (empty() && theRHS.empty())
+ return *this;
+
if (m_allocation < theRHS.m_size)
{
ThisType theTemp(theRHS,*m_memoryManager);
This patch seems to have resolved the problem for me.
> XalanVector assignment operator crash bug
> -----------------------------------------
>
> Key: XALANC-742
> URL: https://issues.apache.org/jira/browse/XALANC-742
> Project: XalanC
> Issue Type: Bug
> Components: XalanC
> Affects Versions: CurrentCVS, 1.11
> Environment: Tested on Windows 7 and RHEL5
> Reporter: Michael Chisholm
> Assignee: Steven J. Hathaway
> Priority: Critical
>
> When assigning an empty XalanVector to another, a NULL dereference and crash
> results. Specifically, the std::copy() statement copies to this->begin(),
> which returns NULL when the vector is empty.
> Here is simple demo code:
> #include <xercesc/util/PlatformUtils.hpp>
> #include <xalanc/Include/XalanVector.hpp>
> using namespace xercesc;
> using namespace xalanc;
> int main(int argc, char* argv[])
> {
> XMLPlatformUtils::Initialize();
> XalanVector<int> vec1;
> XalanVector<int> vec2(XalanMemMgrs::getDefaultXercesMemMgr(), 5);
> vec1 = vec2;
> XMLPlatformUtils::Terminate();
>
> return 0;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]