From 4c033fd4aaade3220407a5f40eae7c4fcfc9caa4 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Sat, 27 Oct 2001 07:30:10 +0000 Subject: [PATCH] fix some range checking for the fountain fill segment type --- Changes | 1 + filters.c | 4 ++-- t/t61filters.t | 9 ++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index afdecd8d..17ba8879 100644 --- a/Changes +++ b/Changes @@ -534,6 +534,7 @@ Revision history for Perl extension Imager. intensity scaling. - constant edge extension for scaling operations - better error checking of automatic fill conversions + - fix some range checking for the fountain fill segment type ================================================================= diff --git a/filters.c b/filters.c index f06e31de..8f89b646 100644 --- a/filters.c +++ b/filters.c @@ -1529,8 +1529,8 @@ fount_init_state(struct fount_state *state, double xa, double ya, i_fountain_seg *seg = my_segs + i; *seg = segs[i]; - if (seg->type < 0 || type >= i_ft_end) - seg->type = i_ft_linear; + if (seg->type < 0 || seg->type >= i_fst_end) + seg->type = i_fst_linear; if (seg->color < 0 || seg->color >= i_fc_end) seg->color = i_fc_direct; if (seg->color == i_fc_hue_up || seg->color == i_fc_hue_down) { diff --git a/t/t61filters.t b/t/t61filters.t index ad06f7a6..8708f9bf 100644 --- a/t/t61filters.t +++ b/t/t61filters.t @@ -9,7 +9,7 @@ $imbase->open(file=>'testout/t104.ppm') or die; my $im_other = Imager->new(xsize=>150, ysize=>150); $im_other->box(xmin=>30, ymin=>60, xmax=>120, ymax=>90, filled=>1); -print "1..41\n"; +print "1..43\n"; test($imbase, 1, {type=>'autolevels'}, 'testout/t61_autolev.ppm'); @@ -84,6 +84,13 @@ test($imbase, 38, { type=>'unsharpmask', stddev=>2.0 }, test($imbase, 40, {type=>'conv', coef=>[ -1, 3, -1, ], }, 'testout/t61_conv_sharp.ppm'); +# Regression test: the checking of the segment type was incorrect +# (the comparison was checking the wrong variable against the wrong value) +my $f4 = [ [ 0, 0.5, 1, NC(0,0,0), NC(255,255,255), 5, 0 ] ]; +test($imbase, 42, {type=>'fountain', xa=>75, ya=>75, xb=>90, yb=>15, + segments=>$f4, super_sample=>'grid', + ftype=>'linear', combine=>'color' }, + 'testout/t61_regress_fount.ppm'); sub test { my ($in, $num, $params, $out) = @_; -- 2.39.5