4
0
mirror of https://github.com/QuasarApp/pe-parse.git synced 2025-05-10 10:29:32 +00:00
This commit is contained in:
munin 2013-08-05 11:53:47 -04:00
parent a67651d1f8
commit 42cf2a4bb0

@ -109,8 +109,12 @@ bounded_buffer *readFileToFileBuffer(const char *filePath) {
struct stat s = {0};
/* should work since fd is open */
fstat(fd, &s);
if(fstat(fd, &s) != 0) {
close(fd);
delete d;
delete p;
return NULL;
}
void *maddr = mmap(NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
@ -189,11 +193,15 @@ void deleteBuffer(bounded_buffer *b) {
}
if(b->copy == false) {
munmap(b->buf, b->bufLen);
close(b->detail->fd);
#ifdef BUF_RAW
free(b->buf);
#endif
}
delete b;
return;
}