diff options
| author | 2014-01-17 20:11:29 +0000 | |
|---|---|---|
| committer | 2014-01-17 20:11:29 +0000 | |
| commit | aa27b97f0b67e8a5e0fa542e6db1af07dc0152d1 (patch) | |
| tree | be9ff97f2b81a7032c82911fb8227690154250e9 | |
| parent | 855bae407d61b5cc6629248e7692927b4dacd92f (diff) | |
| parent | 8582264dbf84aabe18adb113807c1ae8b563b88f (diff) | |
am 8582264d: am 766c95be: am e66fa5c1: am 251de854: am 53e9bfae: Merge "Fix error checking in MemoryFile."
* commit '8582264dbf84aabe18adb113807c1ae8b563b88f':
Fix error checking in MemoryFile.
| -rw-r--r-- | core/jni/android_os_MemoryFile.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/jni/android_os_MemoryFile.cpp b/core/jni/android_os_MemoryFile.cpp index 88a3738de587..27b29bc11930 100644 --- a/core/jni/android_os_MemoryFile.cpp +++ b/core/jni/android_os_MemoryFile.cpp @@ -47,15 +47,16 @@ static jlong android_os_MemoryFile_mmap(JNIEnv* env, jobject clazz, jobject file jint length, jint prot) { int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); - jlong result = (jlong)mmap(NULL, length, prot, MAP_SHARED, fd, 0); - if (!result) + void* result = mmap(NULL, length, prot, MAP_SHARED, fd, 0); + if (result == MAP_FAILED) { jniThrowException(env, "java/io/IOException", "mmap failed"); - return result; + } + return reinterpret_cast<jlong>(result); } static void android_os_MemoryFile_munmap(JNIEnv* env, jobject clazz, jlong addr, jint length) { - int result = munmap((void *)addr, length); + int result = munmap(reinterpret_cast<void *>(addr), length); if (result < 0) jniThrowException(env, "java/io/IOException", "munmap failed"); } |