[pypy-svn] pypy default: Check for memory allocation failure

amauryfa commits-noreply at bitbucket.org
Tue Jan 25 09:12:55 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r41288:35c952fea0fb
Date: 2011-01-25 09:10 +0100
http://bitbucket.org/pypy/pypy/changeset/35c952fea0fb/

Log:	Check for memory allocation failure

diff --git a/pypy/rlib/rdtoa.py b/pypy/rlib/rdtoa.py
--- a/pypy/rlib/rdtoa.py
+++ b/pypy/rlib/rdtoa.py
@@ -216,6 +216,9 @@
             try:
                 digits = dg_dtoa(value, mode, precision,
                                      decpt_ptr, sign_ptr, end_ptr)
+                if not digits:
+                    # The only failure mode is no memory
+                    raise MemoryError
                 try:
                     buflen = (rffi.cast(rffi.LONG, end_ptr[0]) -
                               rffi.cast(rffi.LONG, digits))


More information about the Pypy-commit mailing list