From 0d64f476c62215c7738655f62b89f93ac60c7fe2 Mon Sep 17 00:00:00 2001 From: Earl Ou Date: Wed, 8 Aug 2012 15:19:13 +0800 Subject: Handle error when string length=0 in IfdParser Change-Id: I3a51e85060f3acd5026555e5f8d21f8cb2e0641e --- src/com/android/gallery3d/exif/IfdParser.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/com/android/gallery3d/exif/IfdParser.java') diff --git a/src/com/android/gallery3d/exif/IfdParser.java b/src/com/android/gallery3d/exif/IfdParser.java index b0b0bce10..0d1059cb0 100644 --- a/src/com/android/gallery3d/exif/IfdParser.java +++ b/src/com/android/gallery3d/exif/IfdParser.java @@ -125,9 +125,13 @@ public class IfdParser { } public String readString(int n) throws IOException { - byte[] buf = new byte[n]; - mTiffStream.readOrThrow(buf); - return new String(buf, 0, n - 1, "UTF8"); + if (n > 0) { + byte[] buf = new byte[n]; + mTiffStream.readOrThrow(buf); + return new String(buf, 0, n - 1, "UTF8"); + } else { + return ""; + } } public String readString(int n, Charset charset) throws IOException { -- cgit v1.2.3