From ac7ba7e765b4dbe1473c0a4aec3284c50e6b4619 Mon Sep 17 00:00:00 2001 From: Adrian Cumiskey Date: Tue, 9 Sep 2008 11:00:58 +0000 Subject: [PATCH] Make PFM string parsing a little more robust 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/fop/fonts/type1/PFMInputStream.java b/src/java/org/apache/fop/fonts/type1/PFMInputStream.java index 596bf69bd..85f39b6f3 100644 --- a/src/java/org/apache/fop/fonts/type1/PFMInputStream.java +++ b/src/java/org/apache/fop/fonts/type1/PFMInputStream.java @@ -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(); } -- 2.39.5