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

Commit 00cfbe82 authored by Narayan Kamath's avatar Narayan Kamath Committed by Android Git Automerger
Browse files

am a5608acb: Merge "Don\'t allow MemoryFiles of negative length."

* commit 'a5608acb':
  Don't allow MemoryFiles of negative length.
parents 228cefa8 a5608acb
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -63,12 +63,17 @@ public class MemoryFile
     * Allocates a new ashmem region. The region is initially not purgable.
     *
     * @param name optional name for the file (can be null).
     * @param length of the memory file in bytes.
     * @param length of the memory file in bytes, must be non-negative.
     * @throws IOException if the memory file could not be created.
     */
    public MemoryFile(String name, int length) throws IOException {
        mLength = length;
        if (length >= 0) {
            mFD = native_open(name, length);
        } else {
            throw new IOException("Invalid length: " + length);
        }

        if (length > 0) {
            mAddress = native_mmap(mFD, length, PROT_READ | PROT_WRITE);
        } else {