Skip to content

Commit 0fec6e1

Browse files
committed
address review
1 parent 4db7917 commit 0fec6e1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Modules/_decimal/_decimal.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ dec_from_long(decimal_state *state, PyTypeObject *type, PyObject *v,
23402340
uint8_t sign = export_long.negative ? MPD_NEG : MPD_POS;
23412341
Py_ssize_t len = export_long.ndigits;
23422342

2343-
assert(layout->bits_per_digit <= 32);
2343+
assert(layout->bits_per_digit < 32);
23442344
assert(layout->digits_order == -1);
23452345
assert(layout->digit_endianness == (PY_LITTLE_ENDIAN ? -1 : 1));
23462346
assert(layout->digit_size == 2 || layout->digit_size == 4);
@@ -3681,9 +3681,9 @@ dec_as_long(PyObject *dec, PyObject *context, int round)
36813681
assert(!mpd_iszero(x));
36823682

36833683
const PyLongLayout *layout = PyLong_GetNativeLayout();
3684-
const uint32_t base = (uint32_t)1 << layout->bits_per_digit;
3684+
uint32_t base = (uint32_t)1 << layout->bits_per_digit;
36853685

3686-
assert(layout->bits_per_digit <= 32);
3686+
assert(layout->bits_per_digit < 32);
36873687
assert(layout->digits_order == -1);
36883688
assert(layout->digit_endianness == (PY_LITTLE_ENDIAN ? -1 : 1));
36893689
assert(layout->digit_size == 2 || layout->digit_size == 4);
@@ -3702,11 +3702,11 @@ dec_as_long(PyObject *dec, PyObject *context, int round)
37023702
occur, i.e. len was obtained by a call to mpd_sizeinbase. Set digits
37033703
to zero, as size can be overestimated. */
37043704
if (layout->digit_size == 4) {
3705-
memset(digits, 0, len*sizeof(uint32_t));
3705+
memset(digits, 0, 4*len);
37063706
n = mpd_qexport_u32((uint32_t **)&digits, len, base, x, &status);
37073707
}
37083708
else {
3709-
memset(digits, 0, len*sizeof(uint16_t));
3709+
memset(digits, 0, 2*len);
37103710
n = mpd_qexport_u16((uint16_t **)&digits, len, base, x, &status);
37113711
}
37123712

@@ -3717,7 +3717,7 @@ dec_as_long(PyObject *dec, PyObject *context, int round)
37173717
return NULL;
37183718
}
37193719

3720-
assert(n == len || n == len - 1);
3720+
assert(n <= len);
37213721
mpd_del(x);
37223722
return PyLongWriter_Finish(writer);
37233723
}

0 commit comments

Comments
 (0)