diff --git a/rtl/eclrtl/rtltype.cpp b/rtl/eclrtl/rtltype.cpp index a0f0409b452..c69a79bcddf 100644 --- a/rtl/eclrtl/rtltype.cpp +++ b/rtl/eclrtl/rtltype.cpp @@ -62,7 +62,7 @@ void rtlPadTruncString(unsigned & tgtLen, char * & tgt, unsigned newLen, unsigne { if (len > newLen) len = newLen; - char * buff = (char *)malloc(len); + char * buff = (char *)malloc(newLen); memcpy(buff, src, len); if (len < newLen) memset(buff+len, ' ', newLen - len); @@ -87,10 +87,23 @@ __int64 rtlBcdToInteger(unsigned len, char * src) void rtlIntegerToBcd(unsigned & tgtLen, char * & tgt, unsigned digits, __int64 value) { + tgtLen = (digits + 1) / 2; + tgt = (char *)malloc(tgtLen); + char * cur = tgt + tgtLen - 1; + for (unsigned i = 0; i < digits; i += 2) + { + *cur-- = (value % 10) | ((value / 10 % 10) << 4); + value /= 100; + } } void rtlIntegerToBcdFixed(char * tgt, unsigned digits, __int64 value) { + for (unsigned i = 0; i < digits; i += 2) + { + *tgt++ = (value % 10) | ((value / 10 % 10) << 4); + value /= 100; + } } //============================================================================= diff --git a/system/jlib/jdebug.cpp b/system/jlib/jdebug.cpp index 3aea22a4add..c5608e1b00f 100644 --- a/system/jlib/jdebug.cpp +++ b/system/jlib/jdebug.cpp @@ -3286,7 +3286,6 @@ void printProcMap(const char *fn, bool printbody, bool printsummary, StringBuffe } while (reader.nextln()) { const char *ln = reader.ln; - unsigned n=0; if (*ln) { offset_t start = readHexNum(ln); if (last&&(last!=start)) { @@ -3360,7 +3359,6 @@ void printProcMap(const char *fn, bool printbody, bool printsummary, StringBuffe recs[t].total += ssz; if (ssz>recs[t].largest) recs[t].largest = ssz; - n++; last = end; #ifndef __64BIT__ if ((end<0xffffffff)&&(end>=0xc0000000)) // rest is OS (32-bit only)