mirror of https://github.com/decompals/wibo.git
don't try to mmap 0-sized things (#26)
This commit is contained in:
parent
b65a585ee3
commit
681137902b
|
@ -405,8 +405,10 @@ namespace kernel32 {
|
|||
fclose(fp);
|
||||
}
|
||||
} else if (data.type == handles::TYPE_MAPPED) {
|
||||
if (data.ptr != (void *) 0x1) {
|
||||
munmap(data.ptr, data.size);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -665,7 +667,11 @@ namespace kernel32 {
|
|||
void *mmapped;
|
||||
|
||||
if (hFile == (void*) -1) { // INVALID_HANDLE_VALUE
|
||||
if (size == 0) {
|
||||
mmapped = (void *) 0x1;
|
||||
} else {
|
||||
mmapped = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
|
||||
}
|
||||
} else {
|
||||
int fd = fileno(files::fpFromHandle(hFile));
|
||||
|
||||
|
@ -675,8 +681,13 @@ namespace kernel32 {
|
|||
return (void*) -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
mmapped = (void *) 0x1;
|
||||
} else {
|
||||
mmapped = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
}
|
||||
}
|
||||
|
||||
assert(mmapped != MAP_FAILED);
|
||||
return handles::allocDataHandle({handles::TYPE_MAPPED, mmapped, (unsigned int) size});
|
||||
|
|
Loading…
Reference in New Issue