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.
This commit is contained in:
canyie 2022-02-02 21:37:30 +08:00 committed by John Wu
parent 188546515c
commit ebb0ec6c42

View File

@ -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;
}