[Python-checkins] r46524 - python/trunk/Python/pystrtod.c

georg.brandl python-checkins at python.org
Mon May 29 16:28:05 CEST 2006


Author: georg.brandl
Date: Mon May 29 16:28:05 2006
New Revision: 46524
Modified:
 python/trunk/Python/pystrtod.c
Log:
Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671.
Modified: python/trunk/Python/pystrtod.c
==============================================================================
--- python/trunk/Python/pystrtod.c	(original)
+++ python/trunk/Python/pystrtod.c	Mon May 29 16:28:05 2006
@@ -31,6 +31,7 @@
 * is returned (according to the sign of the value), and %ERANGE is
 * stored in %errno. If the correct value would cause underflow,
 * zero is returned and %ERANGE is stored in %errno.
+ * If memory allocation fails, %ENOMEM is stored in %errno.
 * 
 * This function resets %errno before calling strtod() so that
 * you can reliably detect overflow and underflow.
@@ -102,6 +103,12 @@
 
 		/* We need to convert the '.' to the locale specific decimal point */
 		copy = (char *)PyMem_MALLOC(end - nptr + 1 + decimal_point_len);
+		if (copy == NULL) {
+			if (endptr)
+				*endptr = nptr;
+			errno = ENOMEM;
+			return val;
+		}
 
 		c = copy;
 		memcpy(c, nptr, decimal_point_pos - nptr);


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /