From: Tony Cook Date: Wed, 2 Jan 2019 08:04:33 +0000 (+1100) Subject: avoid dead code in i_ft2_glyph_name() X-Git-Tag: v1.009~23 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/4eb9a521656d98b51eb6279ce0870df692f833b5 avoid dead code in i_ft2_glyph_name() --- diff --git a/Changes b/Changes index fde0e81f..0fa06a20 100644 --- a/Changes +++ b/Changes @@ -69,6 +69,9 @@ High severity: - avoid dead code in i_get_anonymous_color_histo(), which is the implementation of getcolorusage(). CID 185327. + - avoid dead code in i_ft2_glyph_name(), which is the implementation + of glyph_names() for FT2. CID 185342. + Imager 1.008 - 31 Dec 2018 ============ diff --git a/FT2/Changes b/FT2/Changes index 3b7b1ca3..8d6b5e1c 100644 --- a/FT2/Changes +++ b/FT2/Changes @@ -1,3 +1,9 @@ +Imager-Font-FT2 0.95 +==================== + + - avoid dead code in i_ft2_glyph_name(), which is the implementation + of glyph_names(). CID 185342. + Imager-Font-FT2 0.94 ==================== diff --git a/FT2/FT2.pm b/FT2/FT2.pm index e89b1470..93cd707f 100644 --- a/FT2/FT2.pm +++ b/FT2/FT2.pm @@ -6,7 +6,7 @@ use vars qw($VERSION @ISA); @ISA = qw(Imager::Font); BEGIN { - $VERSION = "0.95"; + $VERSION = "0.96"; require XSLoader; XSLoader::load('Imager::Font::FT2', $VERSION); diff --git a/FT2/FT2.xs b/FT2/FT2.xs index 7b9a8b9f..dd934427 100644 --- a/FT2/FT2.xs +++ b/FT2/FT2.xs @@ -303,17 +303,15 @@ i_ft2_glyph_name(handle, text_sv, utf8 = 0, reliable_only = 1) ch = *text++; --len; } - EXTEND(SP, count+1); + EXTEND(SP, 1); if (i_ft2_glyph_name(handle, ch, name, sizeof(name), reliable_only)) { - ST(count) = sv_2mortal(newSVpv(name, 0)); + PUSHs(sv_2mortal(newSVpv(name, 0))); } else { - ST(count) = &PL_sv_undef; + PUSHs(&PL_sv_undef); } - ++count; } - XSRETURN(count); int i_ft2_can_do_glyph_names() diff --git a/FT2/t/t10ft2.t b/FT2/t/t10ft2.t index af965454..4643f9d7 100644 --- a/FT2/t/t10ft2.t +++ b/FT2/t/t10ft2.t @@ -1,6 +1,6 @@ #!perl -w use strict; -use Test::More tests => 204; +use Test::More; use Cwd qw(getcwd abs_path); use Imager qw(:all); @@ -332,6 +332,10 @@ SKIP: my @names = $exfont->glyph_names(string=>$text, utf8=>1, reliable_only=>0); is($names[0], "hyphentwo", "check utf8 glyph name"); + + # make sure we get an empty list with bad utf8 + my @bad = $exfont->glyph_names(string => "ab\xC0", utf8 => 1); + is(@bad, 0, "properly got empty result with bad utf8"); } } @@ -595,6 +599,8 @@ SKIP: Imager->close_log(); +done_testing(); + END { unless ($ENV{IMAGER_KEEP_FILES}) { unlink map "testout/$_", @test_output;