Author: amassari Date: Mon Apr 23 12:44:51 2012 New Revision: 1329216 URL: http://svn.apache.org/viewvc?rev=1329216&view=rev Log: Avoid allocating a 0-byte array, and in any case throw an OutOfMemoryException only if the buffer is NULL and the requested size was not 0 (XERCESC-1979)
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp xerces/c/trunk/src/xercesc/internal/MemoryManagerImpl.cpp Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp?rev=1329216&r1=1329215&r2=1329216&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp (original) +++ xerces/c/trunk/src/xercesc/dom/impl/DOMLSSerializerImpl.cpp Mon Apr 23 12:44:51 2012 @@ -281,7 +281,7 @@ DOMLSSerializerImpl::DOMLSSerializerImpl ,fNamespaceStack(0) ,fMemoryManager(manager) { - fNamespaceStack=new (fMemoryManager) RefVectorOf< RefHashTableOf<XMLCh> >(0,true, fMemoryManager); + fNamespaceStack=new (fMemoryManager) RefVectorOf< RefHashTableOf<XMLCh> >(1,true, fMemoryManager); // // set features to default setting Modified: xerces/c/trunk/src/xercesc/internal/MemoryManagerImpl.cpp URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/MemoryManagerImpl.cpp?rev=1329216&r1=1329215&r2=1329216&view=diff ============================================================================== --- xerces/c/trunk/src/xercesc/internal/MemoryManagerImpl.cpp (original) +++ xerces/c/trunk/src/xercesc/internal/MemoryManagerImpl.cpp Mon Apr 23 12:44:51 2012 @@ -30,7 +30,7 @@ XERCES_CPP_NAMESPACE_BEGIN MemoryManager* MemoryManagerImpl::getExceptionMemoryManager() { - return this; + return this; } void* MemoryManagerImpl::allocate(XMLSize_t size) @@ -42,10 +42,9 @@ void* MemoryManagerImpl::allocate(XMLSiz catch(...) { throw OutOfMemoryException(); } - if (memptr != NULL) { - return memptr; - } - throw OutOfMemoryException(); + if(memptr==NULL && size!=0) + throw OutOfMemoryException(); + return memptr; } void MemoryManagerImpl::deallocate(void* p) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org