diff options
| author | 2018-08-21 03:13:55 -0700 | |
|---|---|---|
| committer | 2018-08-21 03:13:55 -0700 | |
| commit | 1bb899b5f56002899536698b3b85381e229bbba1 (patch) | |
| tree | 60b93d1881c020dfb2df005c60235ff34098195f | |
| parent | 6a4f3fe7c752011ad27573dffcf953dbefb3695d (diff) | |
| parent | 657650eaf0cbd142d94787cd812fc7a9c1d61c2a (diff) | |
Merge "Fix double close in NativeLibraryHelper.openApkFd."
am: 657650eaf0
Change-Id: Idde99d51da9babe9338db50962c025f96ab6637a
| -rw-r--r-- | core/jni/com_android_internal_content_NativeLibraryHelper.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp index cc2646cfb7c0..dc0426987b1e 100644 --- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp +++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp @@ -27,6 +27,7 @@ #include <zlib.h> +#include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> @@ -567,7 +568,14 @@ com_android_internal_content_NativeLibraryHelper_openApkFd(JNIEnv *env, jclass, return 0; } - ZipFileRO* zipFile = ZipFileRO::openFd(fd, debugFilePath.c_str()); + int dupedFd = dup(fd); + if (dupedFd == -1) { + jniThrowExceptionFmt(env, "java/lang/IllegalArgumentException", + "Failed to dup FileDescriptor: %s", strerror(errno)); + return 0; + } + + ZipFileRO* zipFile = ZipFileRO::openFd(dupedFd, debugFilePath.c_str()); return reinterpret_cast<jlong>(zipFile); } |