Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Small memory leak in 8.5 branch ShorteningBignumConversion()

Closed / Fixed3315098fffffffffffffffffffffffffffffffffCreated 15 years agoUpdated 15 years ago
Descriptionplain2011-06-11 14:46:21
I obsovered 2 small memleaks in connection with bignums and float conversions in the tcl-core-8-5-branch in fossil

==31820== 32 bytes in 1 blocks are definitely lost in loss record 631 of 1,824
==31820==    at 0x1000111FF: malloc (vg_replace_malloc.c:236)
==31820==    by 0x100036185: TclpAlloc (tclAlloc.c:706)
==31820==    by 0x100042A49: Tcl_Alloc (tclCkalloc.c:1056)
==31820==    by 0x10013B995: TclBN_mp_init_size (bn_mp_init_size.c:27)
==31820==    by 0x10013AE1C: TclBN_mp_div_d (bn_mp_div_d.c:78)
==31820==    by 0x10011324A: ShorteningBignumConversion (tclStrToD.c:3745)
==31820==    by 0x1001114FA: TclDoubleDigits (tclStrToD.c:4239)
==31820==    by 0x100120949: Tcl_PrintDouble (tclUtil.c:2848)
==31820==    by 0x1000EE90F: UpdateStringOfDouble (tclObj.c:2299)
==31820==    by 0x1000EDCFD: Tcl_GetString (tclObj.c:1587)

the following simple changes fixes this

===================================================================
--- generic/tclStrToD.c
+++ generic/tclStrToD.c
@@ -3788,11 +3788,11 @@
      * string.
      */
     if (m2plus > m2minus) {
 mp_clear(&mplus);
     }
-    mp_clear_multi(&b, &mminus, &temp, NULL);
+    mp_clear_multi(&b, &mminus, &temp, &dig, &S, NULL);
     *s = '\0';
     *decpt = k;
     if (endPtr) {
 *endPtr = s;
     }
dkf Ticket [3315098fff]: 2 changes [History diff]2011-06-13 16:23:00
dkf Ticket [3315098fff]: 2 changes [History diff]2011-06-13 16:25:12
dgpplain2011-06-13 20:44:19
Thanks for catching that.  Fix commits in progress.
dgpplain2011-06-13 20:44:20
allow_comments - 1
Log in (anonymous is fine) to add a comment.