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

Commit 31186d48 authored by Michael W's avatar Michael W Committed by Arne Coucheron
Browse files

Gallery2: Remove more possible NPEs

getCache can return null ->
check this before proceeding

Change-Id: I834780a4dafbe22f2d345fe5571cb20f3f3e5e2e
parent 56e5d2b0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1718,6 +1718,7 @@ class Bookmarker {
            BlobCache cache = CacheManager.getCache(mContext,
                    BOOKMARK_CACHE_FILE, BOOKMARK_CACHE_MAX_ENTRIES,
                    BOOKMARK_CACHE_MAX_BYTES, BOOKMARK_CACHE_VERSION);
            if (cache == null) return null;

            byte[] data = cache.lookup(uri.hashCode());
            if (data == null) return null;
+6 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ public class ImageCacheService {
     * @return true if the image data is found; false if not found.
     */
    public boolean getImageData(Path path, long timeModified, int type, BytesBuffer buffer) {
        if (mCache == null) return false;

        byte[] key = makeKey(path, timeModified, type);
        long cacheKey = Utils.crc64Long(key);
        try {
@@ -81,6 +83,8 @@ public class ImageCacheService {
    }

    public void putImageData(Path path, long timeModified, int type, byte[] value) {
        if (mCache == null) return;

        byte[] key = makeKey(path, timeModified, type);
        long cacheKey = Utils.crc64Long(key);
        ByteBuffer buffer = ByteBuffer.allocate(key.length + value.length);
@@ -99,6 +103,8 @@ public class ImageCacheService {
    }

    public void clearImageData(Path path, long timeModified, int type) {
        if (mCache == null) return;

        byte[] key = makeKey(path, timeModified, type);
        long cacheKey = Utils.crc64Long(key);
        if (mCache == null) {