From a017d011247b28bd4d3fd7d797144a543a1440b6 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Mon, 31 Mar 2008 16:33:44 +0200 Subject: [PATCH] euler.cc: evalue_derive: handle constant polynomials Usually, polynomials with only a constant term are reduced to that constant. However, the input evalue may contain such polynomials (possibly read from the input) and so we have to deal with them. --- euler.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/euler.cc b/euler.cc index e25465e..b56d203 100644 --- a/euler.cc +++ b/euler.cc @@ -363,9 +363,14 @@ static void evalue_derive(evalue *poly, int var) return; } - assert(poly->x.p->size > 1); + assert(poly->x.p->size >= 1); enode *p = poly->x.p; free_evalue_refs(&p->arr[0]); + if (p->size == 1) { + free(p); + evalue_set_si(poly, 0, 1); + return; + } if (p->size == 2) { value_clear(poly->d); *poly = p->arr[1]; -- 2.11.4.GIT