Minor change

This commit is contained in:
Robin Nicholson 2018-03-15 19:53:38 +01:00
parent 408a1b6e5e
commit 84659a2a43
1 changed files with 4 additions and 3 deletions

View File

@ -10,6 +10,7 @@
#include "elfspy/Fail.h"
namespace spy
{
@ -19,11 +20,11 @@ MFile::MFile(const char* file_name)
if (fd_ < 0) {
Fail() << "Cannot open " << file_name;
}
struct stat file;
if (fstat(fd_, &file) < 0) {
struct stat file_info;
if (fstat(fd_, &file_info) < 0) {
Fail() << "Cannot fstat " << file_name;
}
size_ = file.st_size;
size_ = file_info.st_size;
address_ = reinterpret_cast<unsigned char*>(
mmap(nullptr, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd_, 0));
if (address_ == MAP_FAILED) {