diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc index 36cd6d85..aff0d792 100644 --- a/src/common/linux/dump_symbols.cc +++ b/src/common/linux/dump_symbols.cc @@ -759,7 +759,7 @@ bool DumpSymbols::WriteSymbolFile(const std::string &obj_file, return false; void *obj_base = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, obj_fd, 0); - if (!obj_base) + if (obj_base == MAP_FAILED) return false; MmapWrapper map_wrapper(obj_base, st.st_size); ElfW(Ehdr) *elf_header = reinterpret_cast(obj_base); diff --git a/src/common/linux/file_id.cc b/src/common/linux/file_id.cc index d69d45a9..1adf2a13 100644 --- a/src/common/linux/file_id.cc +++ b/src/common/linux/file_id.cc @@ -101,7 +101,7 @@ bool FileID::ElfFileIdentifier(unsigned char identifier[16]) { } void *base = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); - if (!base) { + if (base == MAP_FAILED) { close(fd); return false; } diff --git a/src/common/solaris/dump_symbols.cc b/src/common/solaris/dump_symbols.cc index df1c5b09..a0697ff9 100644 --- a/src/common/solaris/dump_symbols.cc +++ b/src/common/solaris/dump_symbols.cc @@ -650,7 +650,7 @@ bool DumpSymbols::WriteSymbolFile(const std::string &obj_file, int sym_fd) { return false; void *obj_base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, obj_fd, 0); - if (!obj_base) + if (obj_base == MAP_FAILED)) return false; MmapWrapper map_wrapper(obj_base, st.st_size); GElf_Ehdr elf_header; diff --git a/src/common/solaris/file_id.cc b/src/common/solaris/file_id.cc index 92e7f71f..643a1462 100644 --- a/src/common/solaris/file_id.cc +++ b/src/common/solaris/file_id.cc @@ -151,7 +151,7 @@ bool FileID::ElfFileIdentifier(unsigned char identifier[16]) { return false; void *base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (!base) + if (base == MAP_FAILED) return false; bool success = false;