From: Vladimir V. Kisil Date: Mon, 22 Jun 2020 07:49:00 +0000 (+0200) Subject: [BUGFIX] Prevent crashes in find_common_factor() X-Git-Tag: release_1-7-10~3 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=5f7f81ad35a80e12c6a9a2272e3882387732be4f;hp=933965916b34a17fa77c413dbc23699e26eaa9bf [BUGFIX] Prevent crashes in find_common_factor() These happened if a non-normalised common factor was equal to zero. Thanks to Feng Feng for reporting this bug. --- diff --git a/ginac/normal.cpp b/ginac/normal.cpp index a80e1508..8e44bee2 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -2565,7 +2565,7 @@ static ex find_common_factor(const ex & e, ex & factor, exmap & repl) x *= f; } - if (i == 0) + if (gc.is_zero()) gc = x; else gc = gcd(gc, x); @@ -2576,6 +2576,9 @@ static ex find_common_factor(const ex & e, ex & factor, exmap & repl) if (gc.is_equal(_ex1)) return e; + if (gc.is_zero()) + return _ex0; + // The GCD is the factor we pull out factor *= gc;