Skip to content

Commit

Permalink
Fix issue in readTag when parse Exif
Browse files Browse the repository at this point in the history
When read some Tag of jpeg images,the offset is less than
the IFD0 offset position,then try to copy data above IFD0
as Tag value no matter whether data exists above IFD0,so
null exception occurs in System.arraycopy.This issue can
effect user in two aspects:
1.black thumbnail for some jpeg images in ALbumSetPage
and ALbumPage.
2.force close happens when get details of some jpeg images.

We set offset for this Tag not value on above situation.

Change-Id: I4897e99598321ce57282eb386e74b127900a28c4
  • Loading branch information
lihai authored and usmcamgrimm committed Mar 24, 2018
1 parent d757a17 commit e0a869b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gallerycommon/src/com/android/gallery3d/exif/ExifParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ private ExifTag readTag() throws IOException, ExifInvalidFormatException {
}
// Some invalid images put some undefined data before IFD0.
// Read the data here.
if ((offset < mIfd0Position) && (dataFormat == ExifTag.TYPE_UNDEFINED)) {
if ((offset < mIfd0Position) && (dataFormat == ExifTag.TYPE_UNDEFINED)
&& (mIfd0Position > DEFAULT_IFD0_OFFSET)) {
byte[] buf = new byte[(int) numOfComp];
System.arraycopy(mDataAboveIfd0, (int) offset - DEFAULT_IFD0_OFFSET,
buf, 0, (int) numOfComp);
Expand Down

0 comments on commit e0a869b

Please sign in to comment.