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

Commit 0bd51161 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "jni: more O_CLOEXECs"

parents 774c3ce1 4b3a08c2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -551,7 +551,7 @@ static jobject nativeDecodeFileDescriptor(JNIEnv* env, jobject clazz, jobject fi
    // if we only close the file descriptor and not the file object it is used to
    // create.  If we don't explicitly clean up the file (which in turn closes the
    // descriptor) the buffers allocated internally by fseek will be leaked.
    int dupDescriptor = dup(descriptor);
    int dupDescriptor = fcntl(descriptor, F_DUPFD_CLOEXEC, 0);

    FILE* file = fdopen(dupDescriptor, "r");
    if (file == NULL) {
+1 −1
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ static jobject ImageDecoder_nCreateFd(JNIEnv* env, jobject /*clazz*/,
                               "broken file descriptor; fstat returned -1", nullptr, source);
    }

    int dupDescriptor = dup(descriptor);
    int dupDescriptor = fcntl(descriptor, F_DUPFD_CLOEXEC, 0);
    FILE* file = fdopen(dupDescriptor, "r");
    if (file == NULL) {
        close(dupDescriptor);
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ static jlong NativeLoadFromFd(JNIEnv* env, jclass /*clazz*/, jobject file_descri
    return 0;
  }

  unique_fd dup_fd(::dup(fd));
  unique_fd dup_fd(::fcntl(fd, F_DUPFD_CLOEXEC, 0));
  if (dup_fd < 0) {
    jniThrowIOException(env, errno);
    return 0;
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ struct Header {
namespace android {

static void ReadFile(const char* path, String8& s) {
    int fd = open(path, O_RDONLY);
    int fd = open(path, O_RDONLY | O_CLOEXEC);
    if (fd != -1) {
        char bytes[1024];
        ssize_t byteCount;
+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ android_hardware_SerialPort_open(JNIEnv *env, jobject thiz, jobject fileDescript

    int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
    // duplicate the file descriptor, since ParcelFileDescriptor will eventually close its copy
    fd = dup(fd);
    fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
    if (fd < 0) {
        jniThrowException(env, "java/io/IOException", "Could not open serial port");
        return;
Loading