diff --git a/src/polyxx/polynomial.cpp b/src/polyxx/polynomial.cpp index 0615b6e..a71c51f 100644 --- a/src/polyxx/polynomial.cpp +++ b/src/polyxx/polynomial.cpp @@ -386,6 +386,7 @@ namespace poly { for (std::size_t i = 0; i < size; ++i) { res.emplace_back(tmp[i]); } + tmp.clear(); return res; } @@ -400,6 +401,7 @@ namespace poly { for (std::size_t i = 0; i < size; ++i) { res.emplace_back(tmp[i]); } + tmp.clear(); return res; } diff --git a/src/polyxx/upolynomial.cpp b/src/polyxx/upolynomial.cpp index 90c21c1..9e18c1f 100644 --- a/src/polyxx/upolynomial.cpp +++ b/src/polyxx/upolynomial.cpp @@ -100,16 +100,19 @@ namespace poly { } std::vector coefficients(const UPolynomial& p) { - lp_integer_t coeffs[degree(p) + 1]; + std::vector coeffs; + lp_integer_t *tmp = nullptr; for (std::size_t i = 0; i < degree(p) + 1; ++i) { - lp_integer_construct_from_int(lp_Z, &coeffs[i], 0); + lp_integer_construct_from_int(lp_Z, tmp, 0); + coeffs.push_back(*tmp); } - lp_upolynomial_unpack(p.get_internal(), coeffs); + lp_upolynomial_unpack(p.get_internal(), coeffs.data()); std::vector res; for (std::size_t i = 0; i < degree(p) + 1; ++i) { res.emplace_back(&coeffs[i]); lp_integer_destruct(&coeffs[i]); } + coeffs.clear(); return res; }