]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Make PFM string parsing a little more robust
authorAdrian Cumiskey <acumiskey@apache.org>
Tue, 9 Sep 2008 11:00:58 +0000 (11:00 +0000)
committerAdrian Cumiskey <acumiskey@apache.org>
Tue, 9 Sep 2008 11:00:58 +0000 (11:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@693433 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fonts/type1/PFMInputStream.java

index 596bf69bd86bc10fdde82cfc7086323441144b2b..85f39b6f3aba738ecb9d2c3765d43ecea6aff259 100644 (file)
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts.type1;
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.DataInputStream;
@@ -30,7 +31,7 @@ import java.io.InputStreamReader;
  */
 public class PFMInputStream extends java.io.FilterInputStream {
 
-    private DataInputStream datain;
+    private final DataInputStream datain;
 
     /**
      * Constructs a PFMInputStream based on an InputStream representing the
@@ -97,10 +98,14 @@ public class PFMInputStream extends java.io.FilterInputStream {
     public String readString() throws IOException {
         InputStreamReader reader = new InputStreamReader(in, "ISO-8859-1");
         StringBuffer buf = new StringBuffer();
+
         int ch = reader.read();
         while (ch != 0) {
             buf.append((char)ch);
             ch = reader.read();
+            if (ch == -1) {
+                throw new EOFException("Unexpected end of stream reached");
+            }
         }
         return buf.toString();
     }