Alexandre Julliard : ntdll: Use malloc() to allocate the buffer in get_device_mount_point().

Alexandre Julliard julliard at winehq.org
Tue Jul 14 16:23:37 CDT 2020


Module: wine
Branch: master
Commit: b2d38f15314e39eeb17ec5e02bc6fe78b26420e3
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b2d38f15314e39eeb17ec5e02bc6fe78b26420e3

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Jul 14 10:33:05 2020 +0200

ntdll: Use malloc() to allocate the buffer in get_device_mount_point().

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/file.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 0b9ad4bc22..cee9800fc8 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -947,8 +947,7 @@ static char *get_device_mount_point( dev_t dev )
 
             if (device && !stat( device, &st ) && S_ISBLK(st.st_mode) && st.st_rdev == dev)
             {
-                ret = RtlAllocateHeap( GetProcessHeap(), 0, strlen(entry->mnt_dir) + 1 );
-                if (ret) strcpy( ret, entry->mnt_dir );
+                ret = strdup( entry->mnt_dir );
                 break;
             }
         }
@@ -968,8 +967,7 @@ static char *get_device_mount_point( dev_t dev )
         if (stat( entry[i].f_mntfromname, &st ) == -1) continue;
         if (S_ISBLK(st.st_mode) && st.st_rdev == dev)
         {
-            ret = RtlAllocateHeap( GetProcessHeap(), 0, strlen(entry[i].f_mntonname) + 1 );
-            if (ret) strcpy( ret, entry[i].f_mntonname );
+            ret = strdup( entry[i].f_mntonname );
             break;
         }
     }
@@ -1089,11 +1087,11 @@ static int get_dir_case_sensitivity_attr( const char *dir )
     attr.volattr = ATTR_VOL_INFO|ATTR_VOL_CAPABILITIES;
     if (getattrlist( mntpoint, &attr, &caps, sizeof(caps), 0 ) < 0)
     {
-        RtlFreeHeap( GetProcessHeap(), 0, mntpoint );
+        free( mntpoint );
         add_fs_cache( get_fsid.dev, get_fsid.fsid, TRUE );
         return TRUE;
     }
-    RtlFreeHeap( GetProcessHeap(), 0, mntpoint );
+    free( mntpoint );
     if (caps.size == sizeof(caps) &&
         (caps.caps.valid[VOL_CAPABILITIES_FORMAT] &
          (VOL_CAP_FMT_CASE_SENSITIVE | VOL_CAP_FMT_CASE_PRESERVING)) ==
@@ -3500,7 +3498,7 @@ static NTSTATUS unmount_device( HANDLE handle )
                     if (major(st.st_rdev) == LOOP_MAJOR) ioctl( unix_fd, 0x4c01 /*LOOP_CLR_FD*/, 0 );
 #endif
                 }
-                RtlFreeHeap( GetProcessHeap(), 0, mount_point );
+                free( mount_point );
             }
         }
         if (needs_close) close( unix_fd );




More information about the wine-cvs mailing list