Alexandre Julliard : cabinet: Preserve trailing slash on directory name in Extract().
Alexandre Julliard
julliard at winehq.org
Tue Feb 22 10:36:10 CST 2011
Module: wine
Branch: master
Commit: 130e38e0477b5df2ea9bee0d19269f04bb6427c8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=130e38e0477b5df2ea9bee0d19269f04bb6427c8
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Feb 21 18:19:11 2011 +0100
cabinet: Preserve trailing slash on directory name in Extract().
---
dlls/cabinet/cabinet_main.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/dlls/cabinet/cabinet_main.c b/dlls/cabinet/cabinet_main.c
index 45454f4..1f0daf8 100644
--- a/dlls/cabinet/cabinet_main.c
+++ b/dlls/cabinet/cabinet_main.c
@@ -331,7 +331,7 @@ HRESULT WINAPI Extract(SESSION *dest, LPCSTR szCabName)
{
HRESULT res = S_OK;
HFDI hfdi;
- char *str, *path, *name;
+ char *str, *end, *path = NULL, *name = NULL;
TRACE("(%p, %s)\n", dest, szCabName);
@@ -363,13 +363,22 @@ HRESULT WINAPI Extract(SESSION *dest, LPCSTR szCabName)
}
lstrcpyA(str, szCabName);
- path = str;
- name = strrchr(path, '\\');
- if (name)
- *name++ = 0;
+ if ((end = strrchr(str, '\\')))
+ {
+ end++;
+ name = HeapAlloc( GetProcessHeap(), 0, strlen(end) + 1 );
+ if (!name)
+ {
+ res = E_OUTOFMEMORY;
+ goto end;
+ }
+ strcpy( name, end );
+ *end = 0;
+ path = str;
+ }
else
{
- name = path;
+ name = str;
path = NULL;
}
@@ -379,10 +388,9 @@ HRESULT WINAPI Extract(SESSION *dest, LPCSTR szCabName)
fdi_notify_extract, NULL, dest))
res = HRESULT_FROM_WIN32(GetLastError());
- HeapFree(GetProcessHeap(), 0, str);
end:
-
+ HeapFree(GetProcessHeap(), 0, path);
+ HeapFree(GetProcessHeap(), 0, name);
FDIDestroy(hfdi);
-
return res;
}
More information about the wine-cvs
mailing list