diff --git a/src/common/cvt.cpp b/src/common/cvt.cpp index 1247608265..b00d860fa6 100644 --- a/src/common/cvt.cpp +++ b/src/common/cvt.cpp @@ -379,6 +379,7 @@ static void integer_to_text(const dsc* from, dsc* to, Callbacks* cb) } UCHAR* q = (to->dsc_dtype == dtype_varying) ? to->dsc_address + sizeof(USHORT) : to->dsc_address; + const UCHAR* start = q; /* If negative, put in minus sign */ @@ -389,10 +390,13 @@ static void integer_to_text(const dsc* from, dsc* to, Callbacks* cb) copy number */ if (scale >= 0) + { do { *q++ = *--p; } while (--l); - else { + } + else + { l += scale; /* l > 0 (see postassertion: l+scale > 0 above) */ do { *q++ = *--p; @@ -403,12 +407,16 @@ static void integer_to_text(const dsc* from, dsc* to, Callbacks* cb) } while (++scale); } + cb->validateLength(cb->getToCharset(to->getCharSet()), length, start, TEXT_LEN(to), cb->err); + /* If padding is required, do it now. */ if (pad_count) + { do { *q++ = '0'; } while (--pad_count); + } /* Finish up by padding (if fixed) or computing the actual length (varying string) */