#1372 In C++ mode %new_copy and similar macros in swigmacros.swg don't handle std::bad_alloc

open
nobody
None
5
2014-06-04
2014-06-04
someone
No

%new_copy and similar macros in swigmacros.swg use plain operator new in C++ mode which throws std::bad_alloc when it fails to allocate memory, since this macro is used in typemaps this exception won't be caught and will crash the process.

In C mode this macros use malloc and friend which will simply return NULL, which will cause SWIG to return None,nil or some such in most languages, while not the best behaviour (It should raise a MemoryError or something similar) at least it doesn't crash.

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks