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

Commit 39938186 authored by Dongwon Kang's avatar Dongwon Kang
Browse files

ThumbnailUtils: To fix misuse of FileInputStream.

We need to close it explicitly after using it. Without this, fd will be closed
non-deterministically, and that will break the decode procedure.

Bug: 5808889
Change-Id: Icf9ff9abd6e327b122c6916df9750016b3d1b616
parent 9a03482c
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -104,8 +104,10 @@ public class ThumbnailUtils {
        }

        if (bitmap == null) {
            FileInputStream stream = null;
            try {
                FileDescriptor fd = new FileInputStream(filePath).getFD();
                stream = new FileInputStream(filePath);
                FileDescriptor fd = stream.getFD();
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inSampleSize = 1;
                options.inJustDecodeBounds = true;
@@ -125,7 +127,16 @@ public class ThumbnailUtils {
                Log.e(TAG, "", ex);
            } catch (OutOfMemoryError oom) {
                Log.e(TAG, "Unable to decode file " + filePath + ". OutOfMemoryError.", oom);
            } finally {
                try {
                    if (stream != null) {
                        stream.close();
                    }
                } catch (IOException ex) {
                    Log.e(TAG, "", ex);
                }
            }

        }

        if (kind == Images.Thumbnails.MICRO_KIND) {