[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-security-dev
Subject:    Re: Proposal/Fix for XSECError.hpp
From:       Berin Lautenbach <berin () wingsofhermes ! org>
Date:       2004-12-10 9:08:11
Message-ID: 41B9677B.8050609 () wingsofhermes ! org
[Download RAW message or body]

Hmm.  Yes sounds sensible.

As does getting rid of mfc dependency - something I've been promising to 
do for a while - and do want to do before a 1.2 release.

Cheers,
	Berin

Vadim Ismailov wrote:

> 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
> 
> 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic