From fb3616e06ca20ffe78dfb00b962a2599a46b2a5f Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 29 Jun 2019 18:51:00 +0200 Subject: Clean up 1992 post processing --- src/export/mystdlib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/export/mystdlib.c') diff --git a/src/export/mystdlib.c b/src/export/mystdlib.c index b65f63d..31c991e 100644 --- a/src/export/mystdlib.c +++ b/src/export/mystdlib.c @@ -21,7 +21,9 @@ MAP map_file( char *filename, int readonly ) if( ( map->fh = open( filename, readonly ? O_RDONLY : O_RDWR ) ) >= 0 ) { fstat( map->fh, &fstatus ); - if( ( map->addr = mmap( NULL, map->size = (size_t)fstatus.st_size, + map->size = (size_t)fstatus.st_size; + if (!map->size) return map; + if( ( map->addr = mmap( NULL, map->size, PROT_READ | ( readonly ? 0 : PROT_WRITE), (readonly ? MAP_PRIVATE : MAP_SHARED), map->fh, 0) ) == MAP_FAILED ) { fprintf( stderr, "Mapping file '%s' failed\n", filename ); -- cgit v1.2.3