Menu

#4836 Small memory leak in 8.5 branch ShorteningBignumConversion()

obsolete: 8.5.9
closed-fixed
9
2011-06-13
2011-06-11
gustafn
No

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;
}

Discussion

  • Donal K. Fellows

    • priority: 5 --> 9
    • assigned_to: nobody --> dgp
     
  • Donal K. Fellows

    • labels: --> 48. Number Handling
    • milestone: --> obsolete: 8.5.9
     
  • Don Porter

    Don Porter - 2011-06-13

    Thanks for catching that. Fix commits in progress.

     
  • Don Porter

    Don Porter - 2011-06-13
    • status: open --> closed-fixed