Hi,
Starting from VS.NET 7.0 operator new does not anymore return NULL in
case of allocation error. It throws std::bad_alloc exception instead
(the way it is supposed to be). Therefore following code in
XSECError.hpp not going to work as expected:
---------------------- start -------------------------
#if defined (_WIN32) && defined (_DEBUG)
# define XSECnew( a, b ) \
if (( a = DEBUG_NEW b ) == NULL) { \
throw XSECException (XSECException::MemoryAllocationFail); \
}
#else
# define XSECnew(a, b) \
if ((a = new b) == NULL) { \
throw XSECException (XSECException::MemoryAllocationFail); \
}
#endif
---------------------- end -------------------------
In case allocation errors in higher code are catched by XSECException
when allocation fails (with 7.0 and 7.1 runtimes) std::bad_alloc is
raised instead of XSECException. Therefore I changed XSECError.hpp
like shown below. I didn't check where and how exceptions are catched,
but at least it will work the way author intended it to work.
---------------------- start -------------------------
#if defined(_WIN32) && (_MSC_VER < 1300)
# define XSECnew(a, b) \
if ((a = new b) == NULL) { \
throw XSECException (XSECException::MemoryAllocationFail); \
}
#else
#define XSECnew(a, b) \
try { \
a = new b; \
} catch(...) { \
throw XSECException (XSECException::MemoryAllocationFail); \
}
#endif
---------------------- end -------------------------
I also got rid of DEBUG_NEW MFC macro and MFC dependency in debug
build altogether, but this is different story.
Regards,
Vadim