diff options
Diffstat (limited to 'lib/mpi/mpi-div.c')
-rw-r--r-- | lib/mpi/mpi-div.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/mpi/mpi-div.c b/lib/mpi/mpi-div.c index c3087d1390ce..f68cbbb4d4a4 100644 --- a/lib/mpi/mpi-div.c +++ b/lib/mpi/mpi-div.c | |||
@@ -149,6 +149,9 @@ int mpi_tdiv_qr(MPI quot, MPI rem, MPI num, MPI den) | |||
149 | mpi_ptr_t marker[5]; | 149 | mpi_ptr_t marker[5]; |
150 | int markidx = 0; | 150 | int markidx = 0; |
151 | 151 | ||
152 | if (!dsize) | ||
153 | return -EINVAL; | ||
154 | |||
152 | memset(marker, 0, sizeof(marker)); | 155 | memset(marker, 0, sizeof(marker)); |
153 | 156 | ||
154 | /* Ensure space is enough for quotient and remainder. | 157 | /* Ensure space is enough for quotient and remainder. |
@@ -207,6 +210,8 @@ int mpi_tdiv_qr(MPI quot, MPI rem, MPI num, MPI den) | |||
207 | * numerator would be gradually overwritten by the quotient limbs. */ | 210 | * numerator would be gradually overwritten by the quotient limbs. */ |
208 | if (qp == np) { /* Copy NP object to temporary space. */ | 211 | if (qp == np) { /* Copy NP object to temporary space. */ |
209 | np = marker[markidx++] = mpi_alloc_limb_space(nsize); | 212 | np = marker[markidx++] = mpi_alloc_limb_space(nsize); |
213 | if (!np) | ||
214 | goto nomem; | ||
210 | MPN_COPY(np, qp, nsize); | 215 | MPN_COPY(np, qp, nsize); |
211 | } | 216 | } |
212 | } else /* Put quotient at top of remainder. */ | 217 | } else /* Put quotient at top of remainder. */ |