From 1412dac6805f7e2e5e1e8a7d89ba57abf062bdb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Mon, 29 Dec 2014 23:20:26 +0000 Subject: [PATCH] Shifting any number by zero places is a no-op, but so is shifting zero by any number of places. --- lib/mpi/mpi_shift.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mpi/mpi_shift.c b/lib/mpi/mpi_shift.c index f058eff..789d0dd 100644 --- a/lib/mpi/mpi_shift.c +++ b/lib/mpi/mpi_shift.c @@ -42,8 +42,8 @@ mpi_lshift(cryb_mpi *X, unsigned int c) { unsigned int cl, i; - /* zero shift */ - if (c == 0) + /* operands are zero */ + if (c == 0 || X->msb == 0) return (0); /* make room */ if (mpi_grow(X, X->msb + c) != 0) @@ -79,8 +79,8 @@ mpi_rshift(cryb_mpi *X, unsigned int c) { unsigned int cl, i; - /* zero shift */ - if (c == 0) + /* operands are zero */ + if (c == 0 || X->msb == 0) return (0); /* shift wider than number, result is zero */ if (X->msb <= c) {