diff options
author | weidai <weidai11@users.noreply.github.com> | 2003-08-04 19:00:41 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2003-08-04 19:00:41 +0000 |
commit | 89862d12200bebff8ba59dcbc19eafdb266d6a0d (patch) | |
tree | fb58ae8f9f7914a6a69f7becead49588338698bd /misc.cpp | |
parent | 5c3dbb91a256f810d30e0c8940bf3e90aa70a4a2 (diff) | |
download | cryptopp-git-89862d12200bebff8ba59dcbc19eafdb266d6a0d.tar.gz |
guard against potential integer overflow in allocators
Diffstat (limited to 'misc.cpp')
-rw-r--r-- | misc.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -6,6 +6,7 @@ #include "misc.h" #include "words.h" +#include <new> NAMESPACE_BEGIN(CryptoPP) @@ -75,6 +76,22 @@ unsigned long Crop(unsigned long value, unsigned int size) return value; } +#if !(defined(_MSC_VER) && (_MSC_VER < 1300)) +using std::new_handler; +#endif + +void CallNewHandler() +{ + new_handler newHandler = set_new_handler(NULL); + if (newHandler) + set_new_handler(newHandler); + + if (newHandler) + newHandler(); + else + throw std::bad_alloc(); +} + NAMESPACE_END #endif |