From: Christian Bauer Date: Thu, 20 Dec 2001 14:24:45 +0000 (+0000) Subject: fixed a bug where quo() would call vector::reserve() with a negative argument X-Git-Tag: release_1-0-3~2 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=274c1632d78ec31575c4b3b328d75ad95a7855aa fixed a bug where quo() would call vector::reserve() with a negative argument --- 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))