[gs-cvs] gs/src

L. Peter Deutsch lpd at casper.ghostscript.com
Sat Apr 13 20:10:03 PDT 2002


Update of /cvs/ghostscript/gs/src
In directory casper:/tmp/cvs-serv23157/src

Modified Files:
	zshade.c 
Log Message:

Fix: ShadingType 1 shadings whose Function was an array required the
individual functions to take 1 argument, rather than the correct 2; shadings
whose Function was not an array didn't check that the function took the
correct number of arguments.  (The Genoa FTS does not check either of
these.)


Index: zshade.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/zshade.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- zshade.c	14 Apr 2002 02:48:26 -0000	1.9
+++ zshade.c	14 Apr 2002 03:10:01 -0000	1.10
@@ -224,10 +224,11 @@
 
 /* Collect a Function value. */
 private int
-build_shading_function(i_ctx_t *i_ctx_p, const ref * op, gs_function_t ** ppfn, int num_inputs,
-		       gs_memory_t *mem)
+build_shading_function(i_ctx_t *i_ctx_p, const ref * op, gs_function_t ** ppfn,
+		       int num_inputs, gs_memory_t *mem)
 {
     ref *pFunction;
+    int code;
 
     *ppfn = 0;
     if (dict_find_string(op, "Function", &pFunction) <= 0)
@@ -237,7 +238,6 @@
 	gs_function_t **Functions;
 	uint i;
 	gs_function_AdOt_params_t params;
-	int code;
 
 	check_read(*pFunction);
 	if (size == 0)
@@ -253,7 +253,7 @@
 	    if (code < 0)
 		break;
 	}
-	params.m = 1;
+	params.m = num_inputs;
 	params.Domain = 0;
 	params.n = size;
 	params.Range = 0;
@@ -262,9 +262,16 @@
 	    code = gs_function_AdOt_init(ppfn, &params, mem);
 	if (code < 0)
 	    gs_function_AdOt_free_params(&params, mem);
-	return code;
-    } else
-	return fn_build_function(i_ctx_p, pFunction, ppfn, mem);
+    } else {
+	code = fn_build_function(i_ctx_p, pFunction, ppfn, mem);
+	if (code < 0)
+	    return code;
+	if ((*ppfn)->params.m != num_inputs) {
+	    gs_function_free(*ppfn, true, mem);
+	    return_error(e_rangecheck);
+	}
+    }
+    return code;
 }
 
 /* ------ Build shadings ------ */




More information about the gs-cvs mailing list