aboutsummaryrefslogtreecommitdiffstats
path: root/src/ztrunc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ztrunc.c')
-rw-r--r--src/ztrunc.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/ztrunc.c b/src/ztrunc.c
index d4c31de..3d05c6e 100644
--- a/src/ztrunc.c
+++ b/src/ztrunc.c
@@ -16,6 +16,8 @@ ztrunc(z_t a, z_t b, size_t bits)
chars = CEILING_BITS_TO_CHARS(bits);
a->sign = b->sign;
a->used = chars < b->used ? chars : b->used;
+ if (a->used < chars)
+ bits = 0;
if (a->alloced < b->alloced) {
a->alloced = b->alloced;
a->chars = realloc(a->chars, b->alloced * sizeof(*(a->chars)));