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

Commit 52b82352 authored by Kenny Root's avatar Kenny Root
Browse files

Free created FileMap when uncompressing files

Change-Id: Ice22c4ecb7c129b74bf60cd66ae79e110b017a4a
parent 54d41379
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -636,7 +636,7 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, void* buffer) const
        memcpy(buffer, ptr, uncompLen);
        memcpy(buffer, ptr, uncompLen);
    } else {
    } else {
        if (!inflateBuffer(buffer, ptr, uncompLen, compLen))
        if (!inflateBuffer(buffer, ptr, uncompLen, compLen))
            goto bail;
            goto unmap;
    }
    }


    if (compLen > kSequentialMin)
    if (compLen > kSequentialMin)
@@ -644,6 +644,8 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, void* buffer) const


    result = true;
    result = true;


unmap:
    file->release();
bail:
bail:
    return result;
    return result;
}
}
@@ -667,7 +669,7 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, int fd) const


    getEntryInfo(entry, &method, &uncompLen, &compLen, &offset, NULL, NULL);
    getEntryInfo(entry, &method, &uncompLen, &compLen, &offset, NULL, NULL);


    const FileMap* file = createEntryFileMap(entry);
    FileMap* file = createEntryFileMap(entry);
    if (file == NULL) {
    if (file == NULL) {
        goto bail;
        goto bail;
    }
    }
@@ -678,21 +680,23 @@ bool ZipFileRO::uncompressEntry(ZipEntryRO entry, int fd) const
        ssize_t actual = write(fd, ptr, uncompLen);
        ssize_t actual = write(fd, ptr, uncompLen);
        if (actual < 0) {
        if (actual < 0) {
            LOGE("Write failed: %s\n", strerror(errno));
            LOGE("Write failed: %s\n", strerror(errno));
            goto bail;
            goto unmap;
        } else if ((size_t) actual != uncompLen) {
        } else if ((size_t) actual != uncompLen) {
            LOGE("Partial write during uncompress (%zd of %zd)\n",
            LOGE("Partial write during uncompress (%zd of %zd)\n",
                (size_t)actual, (size_t)uncompLen);
                (size_t)actual, (size_t)uncompLen);
            goto bail;
            goto unmap;
        } else {
        } else {
            LOGI("+++ successful write\n");
            LOGI("+++ successful write\n");
        }
        }
    } else {
    } else {
        if (!inflateBuffer(fd, ptr, uncompLen, compLen))
        if (!inflateBuffer(fd, ptr, uncompLen, compLen))
            goto bail;
            goto unmap;
    }
    }


    result = true;
    result = true;


unmap:
    file->release();
bail:
bail:
    return result;
    return result;
}
}