Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17fc70b1 authored by Chong Zhang's avatar Chong Zhang Committed by android-build-merger
Browse files

Merge "Fix ExifInterface for .heic when meta is at the end"

am: 98c9cd7b

Change-Id: Iad3fabcbbb4f46c1d401c45fe25ea6c39e248efd
parents ccb3d1d6 98c9cd7b
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -2545,13 +2545,18 @@ public class ExifInterface {
                    if (size == 0) {
                    if (size == 0) {
                        return 0;
                        return 0;
                    }
                    }
                    // We don't allow read positions after the available bytes,
                    if (position < 0) {
                    // the input stream won't be able to seek back then.
                    if (position < 0 || position >= in.available()) {
                        return -1;
                        return -1;
                    }
                    }
                    try {
                    try {
                        if (mPosition != position) {
                        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);
                            in.seek(position);
                            mPosition = position;
                            mPosition = position;
                        }
                        }
@@ -2559,8 +2564,8 @@ public class ExifInterface {
                        // If the read will cause us to go over the available bytes,
                        // If the read will cause us to go over the available bytes,
                        // reduce the size so that we stay in the available range.
                        // reduce the size so that we stay in the available range.
                        // Otherwise the input stream may not be able to seek back.
                        // Otherwise the input stream may not be able to seek back.
                        if (mPosition + size > in.available()) {
                        if (size > in.available()) {
                            size = in.available() - (int)mPosition;
                            size = in.available();
                        }
                        }


                        int bytesRead = in.read(buffer, offset, size);
                        int bytesRead = in.read(buffer, offset, size);