From c028aa12237c3f2b4e52905c6872477d7b1d94aa Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Wed, 2 Jan 2019 19:33:16 +1100 Subject: [PATCH] avoid dead code in i_t1_glyph_names(). --- Changes | 3 +++ T1/Changes | 3 +++ T1/T1.xs | 10 ++++------ T1/t/t10type1.t | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index 05e7074b..691def68 100644 --- a/Changes +++ b/Changes @@ -72,6 +72,9 @@ High severity: - avoid dead code in i_ft2_glyph_name(), which is the implementation of glyph_names() for FT2. CID 185342. + - avoid dead code in i_t1_glyph_names(), which is the implementation + of glyph_names() for T1. CID 185322. + - avoid an unneeded EXTEND() call when the FT2 has_chars() implementation returns 0. CID 185292. diff --git a/T1/Changes b/T1/Changes index 252f3fad..9e32cca1 100644 --- a/T1/Changes +++ b/T1/Changes @@ -6,6 +6,9 @@ Coverity detected issue: - adjust a pointer parameter from an array-style declaration with 6 elements to pointer style (since it hasn't been 6 for years.) + - avoid dead code in i_t1_glyph_names(), which is the implementation + of glyph_names() for T1. CID 185322. + Imager::Font::T1 1.024 ====================== diff --git a/T1/T1.xs b/T1/T1.xs index 56348d5c..ff30c958 100644 --- a/T1/T1.xs +++ b/T1/T1.xs @@ -195,16 +195,14 @@ i_t1_glyph_names(font, text_sv, utf8 = 0) ch = *text++; --len; } - EXTEND(SP, count+1); + EXTEND(SP, 1); if (i_t1_glyph_name(font, ch, name, sizeof(name))) { - 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_t1_CLONE_SKIP(...) @@ -216,4 +214,4 @@ i_t1_CLONE_SKIP(...) BOOT: PERL_INITIALIZE_IMAGER_CALLBACKS; - i_t1_start(); \ No newline at end of file + i_t1_start(); diff --git a/T1/t/t10type1.t b/T1/t/t10type1.t index 5c820189..7668641e 100644 --- a/T1/t/t10type1.t +++ b/T1/t/t10type1.t @@ -8,8 +8,6 @@ use Cwd qw(getcwd abs_path); #$Imager::DEBUG=1; -plan tests => 110; - ok($Imager::formats{t1}, "must have t1"); -d "testout" or mkdir "testout"; @@ -194,6 +192,9 @@ SKIP: @glyph_names = $font->glyph_names(string=>$text, utf8=>1); is($glyph_names[0], undef, "expect no glyph_name for \\x{20A1}"); + my @bad = $font->glyph_names(string => "ab\xC0", utf8 => 1); + is(@bad, 0, "should be no results for bad utf8"); + # make sure a missing string parameter is handled correctly eval { $font->glyph_names(); @@ -406,6 +407,7 @@ SKIP: } } +done_testing(); #malloc_state(); -- 2.39.5