From: Christian Bauer Date: Tue, 31 Jul 2001 20:31:19 +0000 (+0000) Subject: fixed potential crash in power:(l)degree() when used with non-integer X-Git-Tag: release_0-9-2~4 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=36c5241d290222f71d501b253e3bbe3097221645 fixed potential crash in power:(l)degree() when used with non-integer exponents --- 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;