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

Commit ec2f506e authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Make host ashmem_create_region more robust."

parents a48dc55f 39180902
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -43,13 +43,18 @@ int ashmem_create_region(const char *ignored __unused, size_t size)
    char template[PATH_MAX];
    snprintf(template, sizeof(template), "/tmp/android-ashmem-%d-XXXXXXXXX", getpid());
    int fd = mkstemp(template);
    if (fd != -1 && TEMP_FAILURE_RETRY(ftruncate(fd, size)) != -1 && unlink(template) != -1) {
        return fd;
    }
    if (fd == -1) return -1;

    unlink(template);

    if (TEMP_FAILURE_RETRY(ftruncate(fd, size)) == -1) {
      close(fd);
      return -1;
    }

    return fd;
}

int ashmem_set_prot_region(int fd __unused, int prot __unused)
{
    return 0;