Fix uninitialized digits when resizing in some cases
This commit is contained in:
parent
7f134f262c
commit
29b9db0079
@ -203,9 +203,10 @@ static int krk_long_resize(KrkLong * num, ssize_t newdigits) {
|
||||
size_t abs = newdigits < 0 ? -newdigits : newdigits;
|
||||
size_t eabs = num->width < 0 ? -num->width : num->width;
|
||||
if (num->width == 0) {
|
||||
num->digits = malloc(sizeof(uint32_t) * newdigits);
|
||||
num->digits = calloc(sizeof(uint32_t), newdigits);
|
||||
} else if (eabs < abs) {
|
||||
num->digits = realloc(num->digits, sizeof(uint32_t) * newdigits);
|
||||
memset(&num->digits[eabs], 0, sizeof(uint32_t)*(abs-eabs));
|
||||
}
|
||||
|
||||
num->width = newdigits;
|
||||
|
Loading…
Reference in New Issue
Block a user