[mp_int] Patch for deallocate(NULL)

In the version of mp_math posted to the vault in Oct 2008 there are several calls to std::allocator::deallocate where the argument pointer can be NULL. This is not compliant with the C++ standard, which states "p must not be null" (Table 6 in 20.1.5 in the Draft Standard that I have access to). Sure enough, when p is null, I get a segmentation fault (using GCC 3.2.3). Attached is a patch with a fix. -- Nathan

I neglected to include a test case that triggers the problem: #include <iostream> #include <boost/cstdint.hpp> #include <boost/mp_math/mp_int.hpp> using namespace boost::mp_math; using namespace std; int main() { mp_int<> a = 1; cout << a << endl; return 0; } On Fri, Jan 9, 2009 at 4:38 PM, Nathan Kitchen <nathan.kitchen@gmail.com> wrote:
In the version of mp_math posted to the vault in Oct 2008 there are several calls to std::allocator::deallocate where the argument pointer can be NULL. This is not compliant with the C++ standard, which states "p must not be null" (Table 6 in 20.1.5 in the Draft Standard that I have access to).
Sure enough, when p is null, I get a segmentation fault (using GCC 3.2.3).
Attached is a patch with a fix.
-- Nathan
participants (1)
-
Nathan Kitchen