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

Commit 73b00501 authored by Ray Chen's avatar Ray Chen
Browse files

Check cursor and URI value for nullity to prevent NPE.

parent 1cf6c2c3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -459,6 +459,7 @@ public class ThumbnailUtil {
        Cursor c = cr.query(thumbUri, THUMB_PROJECTION,
              Thumbnails.IMAGE_ID + "=?",
              new String[]{String.valueOf(origId)}, null);
        if (c == null) return null;
        try {
            if (c.moveToNext()) {
                return ContentUris.withAppendedId(thumbUri, c.getLong(0));
@@ -487,6 +488,7 @@ public class ThumbnailUtil {
        if (thumb == null) return false;
        try {
            Uri uri = getImageThumbnailUri(cr, origId, thumb.getWidth(), thumb.getHeight());
            if (uri == null) return false;
            OutputStream thumbOut = cr.openOutputStream(uri);
            thumb.compress(Bitmap.CompressFormat.JPEG, 85, thumbOut);
            thumbOut.close();