Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5a00ee2

Browse files
committed
set all digits to 0
1 parent fec6666 commit 5a00ee2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Modules/_decimal/_decimal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3697,14 +3697,14 @@ dec_as_long(PyObject *dec, PyObject *context, int round)
36973697

36983698
status = 0;
36993699
/* mpd_qexport_*() functions used here with assumption, that no resizing
3700-
occur, i.e. len was obtained by a call to mpd_sizeinbase. Note that
3701-
it can overestimate size by 1 digit, so set it first to zero. */
3700+
occur, i.e. len was obtained by a call to mpd_sizeinbase. Set digits
3701+
to zero, as size can be overestimated. */
37023702
if (base > UINT16_MAX) {
3703-
((uint32_t *)digits)[len - 1] = 0;
3703+
memset(digits, 0, len*sizeof(uint32_t));
37043704
n = mpd_qexport_u32((uint32_t **)&digits, len, base, x, &status);
37053705
}
37063706
else {
3707-
((uint16_t *)digits)[len - 1] = 0;
3707+
memset(digits, 0, len*sizeof(uint16_t));
37083708
n = mpd_qexport_u16((uint16_t **)&digits, len, base, x, &status);
37093709
}
37103710

0 commit comments

Comments
 (0)