From 76236c59167e95db3dcb086ca530e63f1b31f2ee Mon Sep 17 00:00:00 2001 From: !uv Date: Fri, 3 Sep 2004 12:42:03 +0000 Subject: [PATCH] Fix a segfault that crept in to win32_io.c due to being too rush. (Logical change 1.523) --- libntfs/win32_io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libntfs/win32_io.c b/libntfs/win32_io.c index 1e36584c..32071e25 100644 --- a/libntfs/win32_io.c +++ b/libntfs/win32_io.c @@ -56,7 +56,7 @@ typedef struct ntfs_volume ntfs_volume; #ifndef DiskGeometryGetPartition #define DiskGeometryGetPartition(Geometry) \ - ((PDISK_PARTITION_INFO)((Geometry) + 1)) + ((PDISK_PARTITION_INFO)(&((PDISK_GEOMETRY_EX)buf)->Data)) #endif #ifndef DiskGeometryGetDetect @@ -1056,8 +1056,10 @@ static int ntfs_device_win32_close(struct ntfs_device *dev) } if (fd->vol_handle != INVALID_HANDLE_VALUE) { - ntfs_device_win32_dismount(fd->vol_handle); - ntfs_device_win32_unlock(fd->vol_handle); + if (!NDevReadOnly(dev)) { + ntfs_device_win32_dismount(fd->vol_handle); + ntfs_device_win32_unlock(fd->vol_handle); + } if (!CloseHandle(fd->vol_handle)) Dputs("Error: CloseHandle failed for volume."); }