Commit ebb0ec6c authored by 石松洲's avatar 石松洲 Committed by John Wu

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.
parent 18854651
...@@ -452,6 +452,7 @@ void *xmmap(void *addr, size_t length, int prot, int flags, ...@@ -452,6 +452,7 @@ void *xmmap(void *addr, size_t length, int prot, int flags,
void *ret = mmap(addr, length, prot, flags, fd, offset); void *ret = mmap(addr, length, prot, flags, fd, offset);
if (ret == MAP_FAILED) { if (ret == MAP_FAILED) {
PLOGE("mmap"); PLOGE("mmap");
return nullptr;
} }
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment