Nikolay Sivov : scrrun: Use static sized buffer for drive root.

Alexandre Julliard julliard at winehq.org
Fri Nov 5 17:15:52 CDT 2021


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Thu Nov  4 22:57:11 2021 +0300

scrrun: Use static sized buffer for drive root.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/scrrun/filesystem.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index d537239b3a1..c42096ae1f6 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -99,7 +99,7 @@ struct drive {
     struct provideclassinfo classinfo;
     IDrive IDrive_iface;
     LONG ref;
-    BSTR root;
+    WCHAR root[4];
 };
 
 struct folder {
@@ -835,10 +835,7 @@ static ULONG WINAPI drive_Release(IDrive *iface)
     TRACE("(%p)->(%d)\n", This, ref);
 
     if (!ref)
-    {
-        SysFreeString(This->root);
         heap_free(This);
-    }
 
     return ref;
 }
@@ -1134,28 +1131,21 @@ static const IDriveVtbl drivevtbl = {
 
 static HRESULT create_drive(WCHAR letter, IDrive **drive)
 {
-    struct drive *This;
+    struct drive *object;
 
     *drive = NULL;
 
-    This = heap_alloc(sizeof(*This));
-    if (!This) return E_OUTOFMEMORY;
+    object = heap_alloc(sizeof(*object));
+    if (!object) return E_OUTOFMEMORY;
 
-    This->IDrive_iface.lpVtbl = &drivevtbl;
-    This->ref = 1;
-    This->root = SysAllocStringLen(NULL, 3);
-    if (!This->root)
-    {
-        heap_free(This);
-        return E_OUTOFMEMORY;
-    }
-    This->root[0] = letter;
-    This->root[1] = ':';
-    This->root[2] = '\\';
-    This->root[3] = 0;
+    object->IDrive_iface.lpVtbl = &drivevtbl;
+    object->ref = 1;
+    wcscpy(object->root, L"A:\\");
+    *object->root = letter;
+
+    init_classinfo(&CLSID_Drive, (IUnknown *)&object->IDrive_iface, &object->classinfo);
+    *drive = &object->IDrive_iface;
 
-    init_classinfo(&CLSID_Drive, (IUnknown *)&This->IDrive_iface, &This->classinfo);
-    *drive = &This->IDrive_iface;
     return S_OK;
 }
 




More information about the wine-cvs mailing list