From 36c5241d290222f71d501b253e3bbe3097221645 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Tue, 31 Jul 2001 20:31:19 +0000 Subject: [PATCH] fixed potential crash in power:(l)degree() when used with non-integer exponents --- ginac/power.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/ginac/power.cpp b/ginac/power.cpp index f292ff8b..c1568145 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -240,13 +240,10 @@ ex power::map(map_function & f) const int power::degree(const ex & s) const { - if (is_exactly_of_type(*exponent.bp,numeric)) { - if (basis.is_equal(s)) { - if (ex_to(exponent).is_integer()) - return ex_to(exponent).to_int(); - else - return 0; - } else + if (is_exactly_of_type(*exponent.bp, numeric) && ex_to(exponent).is_integer()) { + if (basis.is_equal(s)) + return ex_to(exponent).to_int(); + else return basis.degree(s) * ex_to(exponent).to_int(); } return 0; @@ -254,13 +251,10 @@ int power::degree(const ex & s) const int power::ldegree(const ex & s) const { - if (is_exactly_of_type(*exponent.bp,numeric)) { - if (basis.is_equal(s)) { - if (ex_to(exponent).is_integer()) - return ex_to(exponent).to_int(); - else - return 0; - } else + if (is_exactly_of_type(*exponent.bp, numeric) && ex_to(exponent).is_integer()) { + if (basis.is_equal(s)) + return ex_to(exponent).to_int(); + else return basis.ldegree(s) * ex_to(exponent).to_int(); } return 0; -- 2.50.0