mirror of
https://github.com/cryb-to/cryb-to.git
synced 2024-11-14 17:55:40 +00:00
In mpi_copy(), any failure should leave the target untouched.
This commit is contained in:
parent
b2ec312d9f
commit
8228f19d5a
1 changed files with 5 additions and 1 deletions
|
@ -136,9 +136,13 @@ mpi_copy(cryb_mpi *X, const cryb_mpi *Y)
|
|||
|
||||
if (X == Y)
|
||||
return (0);
|
||||
mpi_zero(X);
|
||||
if (Y->msb == 0) {
|
||||
mpi_zero(X);
|
||||
return (0);
|
||||
}
|
||||
if (mpi_grow(X, Y->msb) != 0)
|
||||
return (-1);
|
||||
mpi_zero(X);
|
||||
X->msb = Y->msb;
|
||||
X->neg = Y->neg;
|
||||
memcpy(X->words, Y->words, X->size * sizeof *X->words);
|
||||
|
|
Loading…
Reference in a new issue