Skip to content

Commit 7f0ea32

Browse files
committed
Add reminder to dtoa.c to check for updates regularly.
Fix a bug in the memory management in dtoa.c.
1 parent f633ff4 commit 7f0ea32

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Python/dtoa.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
* This is dtoa.c by David M. Gay, downloaded from
2222
* http://www.netlib.org/fp/dtoa.c on April 15, 2009 and modified for
2323
* inclusion into the Python core by Mark E. T. Dickinson and Eric V. Smith.
24-
* The major modifications are as follows:
24+
*
25+
* Please remember to check http://www.netlib.org/fp regularly (and especially
26+
* before any Python release) for bugfixes and updates.
27+
*
28+
* The major modifications from Gay's original code are as follows:
2529
*
2630
* 0. The original code has been specialized to Python's needs by removing
2731
* many of the #ifdef'd sections. In particular, code to support VAX and
@@ -53,6 +57,10 @@
5357
* 5. The code has been reformatted to better fit with Python's
5458
* C style guide (PEP 7).
5559
*
60+
* 6. A bug in the memory allocation has been fixed: to avoid FREEing memory
61+
* that hasn't been MALLOC'ed, private_mem should only be used when k <=
62+
* Kmax.
63+
*
5664
***************************************************************/
5765

5866
/* Please send bug reports for the original dtoa.c code to David M. Gay (dmg
@@ -342,7 +350,7 @@ Balloc(int k)
342350
x = 1 << k;
343351
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
344352
/sizeof(double);
345-
if (pmem_next - private_mem + len <= PRIVATE_mem) {
353+
if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {
346354
rv = (Bigint*)pmem_next;
347355
pmem_next += len;
348356
}

0 commit comments

Comments
 (0)