POLY: fix segfault for non-invertible polynomials

This commit is contained in:
hasufell 2014-06-28 00:48:12 +02:00
parent 03f3901b81
commit 913a585279
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
1 changed files with 4 additions and 2 deletions

View File

@ -329,7 +329,8 @@ poly_inverse_poly_q(fmpz_poly_t Fq,
fmpz_poly_zero(Fq);
while (1) {
while (fmpz_is_zero(fmpz_poly_get_coeff_ptr(f, 0))) {
while (fmpz_poly_get_coeff_ptr(f, 0) &&
fmpz_is_zero(fmpz_poly_get_coeff_ptr(f, 0))) {
for (uint32_t i = 1; i <= params->N; i++) {
fmpz *f_coeff = fmpz_poly_get_coeff_ptr(f, i);
fmpz *c_coeff = fmpz_poly_get_coeff_ptr(c, params->N - i);
@ -444,7 +445,8 @@ poly_inverse_poly_p(fmpz_poly_t Fp,
fmpz_poly_zero(Fp);
while (1) {
while (fmpz_is_zero(fmpz_poly_get_coeff_ptr(f, 0))) {
while (fmpz_poly_get_coeff_ptr(f, 0) &&
fmpz_is_zero(fmpz_poly_get_coeff_ptr(f, 0))) {
for (uint32_t i = 1; i <= params->N; i++) {
fmpz *f_coeff = fmpz_poly_get_coeff_ptr(f, i);
fmpz *c_coeff = fmpz_poly_get_coeff_ptr(c, params->N - i);