From ebb0ec6c4225f0d1980499eb93e7950bcbf11af8 Mon Sep 17 00:00:00 2001 From: canyie Date: Wed, 2 Feb 2022 21:37:30 +0800 Subject: [PATCH] Make xmmap() returns nullptr when fails In the constructor of mmap_data, there are two possible values when fails: nullptr if fstat() fails, and MAP_FAILED if mmap() fails, but mmap_data treated MAP_FAILED as valid address and crashes. --- native/jni/utils/xwrap.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/native/jni/utils/xwrap.cpp b/native/jni/utils/xwrap.cpp index 49ae4babc..39ce56ed5 100644 --- a/native/jni/utils/xwrap.cpp +++ b/native/jni/utils/xwrap.cpp @@ -452,6 +452,7 @@ void *xmmap(void *addr, size_t length, int prot, int flags, void *ret = mmap(addr, length, prot, flags, fd, offset); if (ret == MAP_FAILED) { PLOGE("mmap"); + return nullptr; } return ret; }