Check mmap() return value and unmap at the end
This commit is contained in:
parent
38f429a3d2
commit
fe6144793f
4
tr.c
4
tr.c
|
@ -124,6 +124,8 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
mappings = (wchar_t *)mmap(NULL, 0x110000 * sizeof(wchar_t),
|
mappings = (wchar_t *)mmap(NULL, 0x110000 * sizeof(wchar_t),
|
||||||
PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
|
||||||
|
if (mappings == MAP_FAILED)
|
||||||
|
eprintf("mmap:");
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
default:
|
default:
|
||||||
|
@ -147,5 +149,7 @@ main(int argc, char *argv[])
|
||||||
if(ferror(stdin))
|
if(ferror(stdin))
|
||||||
eprintf("<stdin>: read error:");
|
eprintf("<stdin>: read error:");
|
||||||
|
|
||||||
|
munmap(mappings, 0x110000 * sizeof(wchar_t));
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user