Skip to content

Commit 3d59f12

Browse files
author
serg@serg.mylan
committed
don't return intg=frac=0 from mod
1 parent c9292b8 commit 3d59f12

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

strings/decimal.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ int decimal2string(decimal *from, char *to, int *to_len)
206206
char *s=to;
207207
dec1 *buf, *buf0=from->buf, tmp;
208208

209-
DBUG_ASSERT(*to_len > 2+from->sign);
209+
DBUG_ASSERT(*to_len >= 2+from->sign);
210210

211211
/* removing leading zeroes */
212212
i=((intg-1) % DIG_PER_DEC1)+1;
@@ -1511,6 +1511,11 @@ static int do_div_mod(decimal *from1, decimal *from2,
15111511
intg0=ROUND_UP(prec1-frac1)-(start1-tmp1);
15121512
frac0=ROUND_UP(to->frac);
15131513
error=E_DEC_OK;
1514+
if (unlikely(frac0==0 && intg0==0))
1515+
{
1516+
decimal_make_zero(to);
1517+
goto done;
1518+
}
15141519
if (intg0<=0)
15151520
{
15161521
if (unlikely(-intg0 >= to->len))

0 commit comments

Comments
 (0)