summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chong Zhang <chz@google.com> 2018-12-03 19:37:53 -0800
committer android-build-merger <android-build-merger@google.com> 2018-12-03 19:37:53 -0800
commitc13bfd871da7641c50eb3de65257ce035d88269c (patch)
tree6309538e0b9a3984b87770ec23eb530daf68dbde
parent3af0f3a7c33454b7847a64a7c1ea550e4dbe9432 (diff)
parent79fa7d39c3568fa83f458e1f5d17a9ad6f7105e4 (diff)
Merge "Fix ExifInterface for .heic when meta is at the end" am: 98c9cd7b20 am: 17fc70b1ee
am: 79fa7d39c3 Change-Id: I33880ecff74ecdc2a60b0857b3cb8e8164232030
-rw-r--r--media/java/android/media/ExifInterface.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java
index 01a0cb619bf0..32c4643adad0 100644
--- a/media/java/android/media/ExifInterface.java
+++ b/media/java/android/media/ExifInterface.java
@@ -2635,13 +2635,18 @@ public class ExifInterface {
if (size == 0) {
return 0;
}
- // We don't allow read positions after the available bytes,
- // the input stream won't be able to seek back then.
- if (position < 0 || position >= in.available()) {
+ if (position < 0) {
return -1;
}
try {
if (mPosition != position) {
+ // We don't allow seek to positions after the available bytes,
+ // the input stream won't be able to seek back then.
+ // However, if we hit an exception before (mPosition set to -1),
+ // let it try the seek in hope it might recover.
+ if (mPosition >= 0 && position >= mPosition + in.available()) {
+ return -1;
+ }
in.seek(position);
mPosition = position;
}
@@ -2649,8 +2654,8 @@ public class ExifInterface {
// If the read will cause us to go over the available bytes,
// reduce the size so that we stay in the available range.
// Otherwise the input stream may not be able to seek back.
- if (mPosition + size > in.available()) {
- size = in.available() - (int)mPosition;
+ if (size > in.available()) {
+ size = in.available();
}
int bytesRead = in.read(buffer, offset, size);