]> www.ginac.de Git - ginac.git/blobdiff - ginac/normal.cpp
[BUGFIX] Prevent crashes in find_common_factor()
[ginac.git] / ginac / normal.cpp
index a80e15084c3affee06491acdba6013aaae0ee2ee..8e44bee24db29555bb4ad43794b560bcabc17ad3 100644 (file)
@@ -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;