From 274c1632d78ec31575c4b3b328d75ad95a7855aa Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Thu, 20 Dec 2001 14:24:45 +0000 Subject: [PATCH] fixed a bug where quo() would call vector::reserve() with a negative argument --- ginac/normal.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ginac/normal.cpp b/ginac/normal.cpp index a161f821..4b490ed0 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -381,7 +381,7 @@ ex quo(const ex &a, const ex &b, const symbol &x, bool check_args) int rdeg = r.degree(x); ex blcoeff = b.expand().coeff(x, bdeg); bool blcoeff_is_numeric = is_ex_exactly_of_type(blcoeff, numeric); - exvector v; v.reserve(rdeg - bdeg + 1); + exvector v; v.reserve(std::max(rdeg - bdeg + 1, 0)); while (rdeg >= bdeg) { ex term, rcoeff = r.coeff(x, rdeg); if (blcoeff_is_numeric) @@ -620,7 +620,7 @@ bool divide(const ex &a, const ex &b, ex &q, bool check_args) int rdeg = r.degree(*x); ex blcoeff = b.expand().coeff(*x, bdeg); bool blcoeff_is_numeric = is_ex_exactly_of_type(blcoeff, numeric); - exvector v; v.reserve(rdeg - bdeg + 1); + exvector v; v.reserve(std::max(rdeg - bdeg + 1, 0)); while (rdeg >= bdeg) { ex term, rcoeff = r.coeff(*x, rdeg); if (blcoeff_is_numeric) @@ -781,7 +781,7 @@ static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_ite int rdeg = adeg; ex eb = b.expand(); ex blcoeff = eb.coeff(*x, bdeg); - exvector v; v.reserve(rdeg - bdeg + 1); + exvector v; v.reserve(std::max(rdeg - bdeg + 1, 0)); while (rdeg >= bdeg) { ex term, rcoeff = r.coeff(*x, rdeg); if (!divide_in_z(rcoeff, blcoeff, term, var+1)) -- 2.44.0