avoid dead code in i_t1_glyph_names().
authorTony Cook <tony@develop-help.com>
Wed, 2 Jan 2019 08:33:16 +0000 (19:33 +1100)
committerTony Cook <tony@develop-help.com>
Wed, 2 Jan 2019 08:33:16 +0000 (19:33 +1100)
Changes
T1/Changes
T1/T1.xs
T1/t/t10type1.t

diff --git a/Changes b/Changes
index 05e7074..691def6 100644 (file)
--- 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.
 
index 252f3fa..9e32cca 100644 (file)
@@ -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
 ======================
 
index 56348d5..ff30c95 100644 (file)
--- 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();
index 5c82018..7668641 100644 (file)
@@ -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();