[Gridflow-cvs] [svn] commit: r3663 - /trunk/base/flow_objects.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri Apr 25 22:18:21 EDT 2008


Author: matju
Date: Fri Apr 25 22:18:19 2008
New Revision: 3663

Log:
fix SIGFPE crash caused by division by zero (FPE is a serious misnomer here) in [#store].

Modified:
    trunk/base/flow_objects.c

Modified: trunk/base/flow_objects.c
==============================================================================
--- trunk/base/flow_objects.c (original)
+++ trunk/base/flow_objects.c Fri Apr 25 22:18:19 2008
@@ -430,13 +430,11 @@
 	int32 v[Dim::MAX_DIM];
 	if (na<1) RAISE("must have at least 1 dimension.",na,1,1+nb);
 	long nc = in->dim->get(na-1);
-	if (nc > nb)
-		RAISE("got %d elements in last dimension, expecting <= %d", nc, nb);
-	int lastindexable = r->dim->prod()/r->dim->prod(nc) - 1;
+	if (nc>nb) RAISE("got %d elements in last dimension, expecting <= %d", nc, nb);
+	long nnc = r->dim->prod(nnc);
+	int lastindexable = nnc ? r->dim->prod()/nnc-1 : 0; // SIGFPE happened when r was especially empty (nnc==0)
 	int ngreatest = nt_greatest((T *)0);
-	if (lastindexable > ngreatest) {
-		RAISE("lastindexable=%d > ngreatest=%d (ask matju)",lastindexable,ngreatest);
-	}
+	if (lastindexable > ngreatest) RAISE("lastindexable=%d > ngreatest=%d (ask matju)",lastindexable,ngreatest);
 	int nd = nb-nc+na-1;
 	COPY(v,in->dim->v,na-1);
 	COPY(v+na-1,r->dim->v+nc,nb-nc);



More information about the Gridflow-cvs mailing list