Partial fix for 687029, Different results on Alpha, part 4

Alex Cherepanov <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.patches
Organization Coscript Software
Message-ID <[email protected]>
Avoid division by 0. Don't interpolate constant functions.

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
gscie.c.diff (text/plain, 1.3 KB)
Index: gs/src/gscie.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gscie.c,v
retrieving revision 1.13
diff -b -u -r1.13 gscie.c
--- gs/src/gscie.c	16 Jun 2002 05:48:55 -0000	1.13
+++ gs/src/gscie.c	24 Nov 2003 23:36:45 -0000
@@ -589,6 +589,15 @@
     cie_cache_range_temp_t temp[3];
     int i, j;
 
+    if (factor == 0) {
+        /* Disable interpolation by setting an empty range. */
+        for (j = 0; j < 3; ++j) {
+  	    pcache->vecs.params.interpolation_ranges[j].rmin = 0;
+	    pcache->vecs.params.interpolation_ranges[j].rmax = -1;
+        }
+        return;
+    }
+
     for (j = 0; j < 3; ++j)
 	temp[j].imin = gx_cie_cache_size, temp[j].imax = -1;
     temp[0].prev = pcache->vecs.values[0].u;
@@ -630,9 +639,8 @@
 
     pcache->vecs.params.base = float2cie_cached(pcf->params.base);
     pcache->vecs.params.factor = float2cie_cached(pcf->params.factor);
-    pcache->vecs.params.limit =
-	float2cie_cached((gx_cie_cache_size - 1) / pcf->params.factor +
-			 pcf->params.base);
+    pcache->vecs.params.limit = float2cie_cached( (pcf->params.factor == 0 ? 0 :
+       (gx_cie_cache_size - 1) / pcf->params.factor) + pcf->params.base);
     for (i = 0; i < gx_cie_cache_size; ++i) {
 	float f = pcf->values[i];
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.