summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2005-09-23 16:13:14 (GMT)
committerdgp <dgp@users.sourceforge.net>2005-09-23 16:13:14 (GMT)
commitc7b393a3ed203cac9b82d8a74ea8423b7be92c14 (patch)
tree6dcabfeb086c5e0ae4e033952a8ca725e806c734
parent5564c15da2806d526d3c13299f77ab6e9c9c7fde (diff)
downloadtcl-c7b393a3ed203cac9b82d8a74ea8423b7be92c14.zip
tcl-c7b393a3ed203cac9b82d8a74ea8423b7be92c14.tar.gz
tcl-c7b393a3ed203cac9b82d8a74ea8423b7be92c14.tar.bz2
[kennykb-numerics-branch]
* generic/tclStrToD.c: Fixed memory leak. [Bug 1299803]. * generic/tclObj.c:
-rw-r--r--ChangeLog15
-rw-r--r--generic/tclObj.c13
2 files changed, 11 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index ee3029e..a06736c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,19 +2,8 @@
[kennykb-numerics-branch]
- * generic/tclStrToD.c: Memory leak. Comment in TclSetBignumIntRep
- * generic/tclObj.c: indicates that mp_init() is called on the
- bignumValue argument to clear it, while keeping the digits array
- transferred to the interp of the Tcl_Obj. The implication is that
- callers of TclSetBignumIntRep() (and their callers) need not call
- mp_clear(), but can imagine they've transferred ownership of an
- mp_int value to Tcl. However, mp_init() doesn't merely re-initialize
- the fields of an mp_int to hold the value zero. It also allocates
- a fresh dp array of minimum size governed by MP_PREC. Without a
- corresponding mp_clear() call somewhere, these dp arrays are leaked.
- Added some mp_clear() calls to fix the leak, but better fix strategies
- should still be pursued. Perhaps the best approach is to just
- invade the mp_int struct and do the necessary surgery ourselves.
+ * generic/tclStrToD.c: Fixed memory leak. [Bug 1299803].
+ * generic/tclObj.c:
2005-09-20 Don Porter <dgp@users.sourceforge.net>
diff --git a/generic/tclObj.c b/generic/tclObj.c
index e0ba40b..2367fb3 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclObj.c,v 1.72.2.37 2005/09/23 04:03:43 dgp Exp $
+ * RCS: @(#) $Id: tclObj.c,v 1.72.2.38 2005/09/23 16:13:14 dgp Exp $
*/
#include "tclInt.h"
@@ -2914,7 +2914,6 @@ Tcl_SetBignumObj(
TclInvalidateStringRep(objPtr);
TclFreeIntRep(objPtr);
TclSetBignumIntRep(objPtr, bignumValue);
- mp_clear(bignumValue);
}
void
@@ -2925,9 +2924,15 @@ TclSetBignumIntRep(objPtr, bignumValue)
objPtr->typePtr = &tclBignumType;
PACK_BIGNUM(*bignumValue, objPtr);
- /* Clear the value with mp_init; mp_clear overwrites the digit array. */
+ /*
+ * Clear the mp_int value.
+ * Don't call mp_clear() because it would free the digit array
+ * we just packed into the Tcl_Obj.
+ */
- mp_init(bignumValue);
+ bignumValue->dp = NULL;
+ bignumValue->alloc = bignumValue->used = 0;
+ bignumValue->sign = MP_NEG;
}
/*