[hackers] [sbase] Check mmap() return value and unmap at the end || sin
commit fe6144793fe7d2a4d674204f675d2e48a2fe06d2
Author: sin <sin_AT_2f30.org>
Date: Mon Jan 20 11:25:57 2014 +0000
Check mmap() return value and unmap at the end
diff --git a/tr.c b/tr.c
index 8cca430..a4ddef9 100644
--- a/tr.c
+++ b/tr.c
_AT_@ -124,6 +124,8 @@ main(int argc, char *argv[])
mappings = (wchar_t *)mmap(NULL, 0x110000 * sizeof(wchar_t),
PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
+ if (mappings == MAP_FAILED)
+ eprintf("mmap:");
ARGBEGIN {
default:
_AT_@ -147,5 +149,7 @@ main(int argc, char *argv[])
if(ferror(stdin))
eprintf("<stdin>: read error:");
+ munmap(mappings, 0x110000 * sizeof(wchar_t));
+
return EXIT_SUCCESS;
}
Received on Mon Jan 20 2014 - 12:28:25 CET
This archive was generated by hypermail 2.3.0
: Mon Jan 20 2014 - 12:36:09 CET