When a virtualized file is created the file->global_map will not
point to a mmapped region, thus it's not safe to use munmap() during
the file cleanup. Only use munmap() if the file is backed by a FD.
Fixes: T5234.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
free(map);
}
- if (!file->copied && file->global_map != MAP_FAILED)
- munmap(file->global_map, file->length);
-
- if (file->fd != -1) close(file->fd);
+ if (file->fd != -1)
+ {
+ if (file->global_map != MAP_FAILED)
+ munmap(file->global_map, file->length);
+ close(file->fd);
+ }
}
static void
free(map);
}
- if (file->global_map != MAP_FAILED)
- UnmapViewOfFile(file->global_map);
-
if (file->handle != INVALID_HANDLE_VALUE)
- CloseHandle(file->handle);
+ {
+ if (file->global_map != MAP_FAILED)
+ UnmapViewOfFile(file->global_map);
+ CloseHandle(file->handle);
+ }
}
static void