From: Tony Cook <tony@develop-help.com> Date: Mon, 31 Dec 2018 11:34:06 +0000 (+1100) Subject: Imager::Color set_internal is now simpler X-Git-Tag: v1.009~35 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/b73468656b21fdab53413f9567b1607f09f4c3ec Imager::Color set_internal is now simpler Coverity complained that ICL_set_internal() could leak here, but that's only possible with a NULL pointer PTROBJ, which would break in many other ways. --- diff --git a/Changes b/Changes index 27b0f412..e115b31b 100644 --- a/Changes +++ b/Changes @@ -26,6 +26,11 @@ Coverity finally finished a build, fix a few problems: Negative values (which Coverity didn't complain about) could also cause problems. + - the Imager::Color set_internal() interal method no longer + calls the over-complicated ICL_set_internal() (which is retained + only for the old API.) Coverity complained that this leaked, but + this could only occur with an invalid (NULL pointer) color object. + Imager 1.008 - 31 Dec 2018 ============ diff --git a/Imager.xs b/Imager.xs index a69fec9e..9307d16a 100644 --- a/Imager.xs +++ b/Imager.xs @@ -1105,7 +1105,10 @@ ICL_set_internal(cl,r,g,b,a) unsigned char b unsigned char a PPCODE: - ICL_set_internal(cl, r, g, b, a); + cl->rgba.r = r; + cl->rgba.g = g; + cl->rgba.b = b; + cl->rgba.a = a; EXTEND(SP, 1); PUSHs(ST(0)); diff --git a/t/100-base/020-color.t b/t/100-base/020-color.t index b6d4f061..cfc2bc3f 100644 --- a/t/100-base/020-color.t +++ b/t/100-base/020-color.t @@ -7,7 +7,7 @@ # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) -use Test::More tests => 73; +use Test::More; use Imager; use Imager::Test qw(is_fcolor3 is_fcolor4 is_color4); @@ -30,8 +30,8 @@ for (1..1000) { my $fail; for (@foo) { Imager::Color::set_internal($_, 128, 128, 128, 128) == $_ or ++$fail; - Imager::Color::set_internal($_, 128, 128, 128, 128) == $_ or ++$fail; - test_col($_, 128, 128, 128, 128) or ++$fail; + Imager::Color::set_internal($_, 128, 129, 130, 131) == $_ or ++$fail; + test_col($_, 128, 129, 130, 131) or ++$fail; } ok(!$fail, 'consitency check'); @@ -269,6 +269,8 @@ is_color4(Imager::Color->new(builtin=>'black'), 0, 0, 0, 255, 'builtin black'); is($v,0,'black value'); } +done_testing(); + sub test_col { my ($c, $r, $g, $b, $a) = @_; unless ($c) {