Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
d34d0c10
Commit
d34d0c10
authored
Nov 20, 2022
by
Alex Henrie
Committed by
Alexandre Julliard
Nov 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
appwiz: Use standard C functions for memory allocation.
parent
82c45159
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
47 deletions
+30
-47
addons.c
dlls/appwiz.cpl/addons.c
+28
-28
appwiz.h
dlls/appwiz.cpl/appwiz.h
+2
-19
No files found.
dlls/appwiz.cpl/addons.c
View file @
d34d0c10
...
@@ -193,7 +193,7 @@ static enum install_res install_from_dos_file(const WCHAR *dir, const WCHAR *sub
...
@@ -193,7 +193,7 @@ static enum install_res install_from_dos_file(const WCHAR *dir, const WCHAR *sub
HRESULT
hr
;
HRESULT
hr
;
size
+=
lstrlenW
(
subdir
)
+
lstrlenW
(
file_name
)
+
2
;
size
+=
lstrlenW
(
subdir
)
+
lstrlenW
(
file_name
)
+
2
;
if
(
!
(
path
=
heap_
alloc
(
size
*
sizeof
(
WCHAR
)
)))
return
INSTALL_FAILED
;
if
(
!
(
path
=
m
alloc
(
size
*
sizeof
(
WCHAR
)
)))
return
INSTALL_FAILED
;
lstrcpyW
(
path
,
dir
);
lstrcpyW
(
path
,
dir
);
if
(
!
wcsncmp
(
path
,
L"
\\
??
\\
"
,
4
))
path
[
1
]
=
'\\'
;
/* change \??\ into \\?\ */
if
(
!
wcsncmp
(
path
,
L"
\\
??
\\
"
,
4
))
path
[
1
]
=
'\\'
;
/* change \??\ into \\?\ */
...
@@ -207,10 +207,10 @@ static enum install_res install_from_dos_file(const WCHAR *dir, const WCHAR *sub
...
@@ -207,10 +207,10 @@ static enum install_res install_from_dos_file(const WCHAR *dir, const WCHAR *sub
if
(
FAILED
(
hr
))
if
(
FAILED
(
hr
))
{
{
ERR
(
"Failed to canonicalize %s, hr %#lx
\n
"
,
debugstr_w
(
path
),
hr
);
ERR
(
"Failed to canonicalize %s, hr %#lx
\n
"
,
debugstr_w
(
path
),
hr
);
heap_
free
(
path
);
free
(
path
);
return
INSTALL_NEXT
;
return
INSTALL_NEXT
;
}
}
heap_
free
(
path
);
free
(
path
);
if
(
GetFileAttributesW
(
canonical_path
)
==
INVALID_FILE_ATTRIBUTES
)
if
(
GetFileAttributesW
(
canonical_path
)
==
INVALID_FILE_ATTRIBUTES
)
{
{
...
@@ -233,7 +233,7 @@ static enum install_res install_from_unix_file(const char *dir, const WCHAR *sub
...
@@ -233,7 +233,7 @@ static enum install_res install_from_unix_file(const char *dir, const WCHAR *sub
if
(
p_wine_get_dos_file_name
&&
(
dos_dir
=
p_wine_get_dos_file_name
(
dir
)))
if
(
p_wine_get_dos_file_name
&&
(
dos_dir
=
p_wine_get_dos_file_name
(
dir
)))
{
{
ret
=
install_from_dos_file
(
dos_dir
,
subdir
,
file_name
);
ret
=
install_from_dos_file
(
dos_dir
,
subdir
,
file_name
);
heap_
free
(
dos_dir
);
free
(
dos_dir
);
}
}
return
ret
;
return
ret
;
}
}
...
@@ -264,24 +264,24 @@ static enum install_res install_from_registered_dir(void)
...
@@ -264,24 +264,24 @@ static enum install_res install_from_registered_dir(void)
if
(
!
hkey
)
if
(
!
hkey
)
return
INSTALL_NEXT
;
return
INSTALL_NEXT
;
package_dir
=
heap_
alloc
(
size
);
package_dir
=
m
alloc
(
size
);
res
=
RegGetValueA
(
hkey
,
NULL
,
addon
->
dir_config_key
,
RRF_RT_ANY
,
&
type
,
(
PBYTE
)
package_dir
,
&
size
);
res
=
RegGetValueA
(
hkey
,
NULL
,
addon
->
dir_config_key
,
RRF_RT_ANY
,
&
type
,
(
PBYTE
)
package_dir
,
&
size
);
if
(
res
==
ERROR_MORE_DATA
)
{
if
(
res
==
ERROR_MORE_DATA
)
{
package_dir
=
heap_
realloc
(
package_dir
,
size
);
package_dir
=
realloc
(
package_dir
,
size
);
res
=
RegGetValueA
(
hkey
,
NULL
,
addon
->
dir_config_key
,
RRF_RT_ANY
,
&
type
,
(
PBYTE
)
package_dir
,
&
size
);
res
=
RegGetValueA
(
hkey
,
NULL
,
addon
->
dir_config_key
,
RRF_RT_ANY
,
&
type
,
(
PBYTE
)
package_dir
,
&
size
);
}
}
RegCloseKey
(
hkey
);
RegCloseKey
(
hkey
);
if
(
res
==
ERROR_FILE_NOT_FOUND
)
{
if
(
res
==
ERROR_FILE_NOT_FOUND
)
{
heap_
free
(
package_dir
);
free
(
package_dir
);
return
INSTALL_NEXT
;
return
INSTALL_NEXT
;
}
else
if
(
res
!=
ERROR_SUCCESS
||
(
type
!=
REG_SZ
&&
type
!=
REG_EXPAND_SZ
))
{
}
else
if
(
res
!=
ERROR_SUCCESS
||
(
type
!=
REG_SZ
&&
type
!=
REG_EXPAND_SZ
))
{
heap_
free
(
package_dir
);
free
(
package_dir
);
return
INSTALL_FAILED
;
return
INSTALL_FAILED
;
}
}
ret
=
install_from_unix_file
(
package_dir
,
L""
,
addon
->
file_name
);
ret
=
install_from_unix_file
(
package_dir
,
L""
,
addon
->
file_name
);
heap_
free
(
package_dir
);
free
(
package_dir
);
return
ret
;
return
ret
;
}
}
...
@@ -293,7 +293,7 @@ static enum install_res install_from_default_dir(void)
...
@@ -293,7 +293,7 @@ static enum install_res install_from_default_dir(void)
if
((
package_dir
=
_wgetenv
(
L"WINEBUILDDIR"
)))
if
((
package_dir
=
_wgetenv
(
L"WINEBUILDDIR"
)))
{
{
dir_buf
=
heap_alloc
(
lstrlenW
(
package_dir
)
*
sizeof
(
WCHAR
)
+
sizeof
(
L"
\\
..
\\
"
)
);
dir_buf
=
malloc
(
wcslen
(
package_dir
)
*
sizeof
(
WCHAR
)
+
sizeof
(
L"
\\
..
\\
"
)
);
lstrcpyW
(
dir_buf
,
package_dir
);
lstrcpyW
(
dir_buf
,
package_dir
);
lstrcatW
(
dir_buf
,
L"
\\
..
\\
"
);
lstrcatW
(
dir_buf
,
L"
\\
..
\\
"
);
package_dir
=
dir_buf
;
package_dir
=
dir_buf
;
...
@@ -303,7 +303,7 @@ static enum install_res install_from_default_dir(void)
...
@@ -303,7 +303,7 @@ static enum install_res install_from_default_dir(void)
if
(
package_dir
)
if
(
package_dir
)
{
{
ret
=
install_from_dos_file
(
package_dir
,
addon
->
subdir_name
,
addon
->
file_name
);
ret
=
install_from_dos_file
(
package_dir
,
addon
->
subdir_name
,
addon
->
file_name
);
heap_
free
(
dir_buf
);
free
(
dir_buf
);
}
}
if
(
ret
==
INSTALL_NEXT
)
if
(
ret
==
INSTALL_NEXT
)
...
@@ -329,7 +329,7 @@ static WCHAR *get_cache_file_name(BOOL ensure_exists)
...
@@ -329,7 +329,7 @@ static WCHAR *get_cache_file_name(BOOL ensure_exists)
}
}
else
if
((
home_dir
=
_wgetenv
(
L"WINEHOMEDIR"
)))
else
if
((
home_dir
=
_wgetenv
(
L"WINEHOMEDIR"
)))
{
{
if
(
!
(
cache_dir
=
heap_alloc
(
lstrlenW
(
home_dir
)
*
sizeof
(
WCHAR
)
+
sizeof
(
L"
\\
.cache"
)
)))
return
NULL
;
if
(
!
(
cache_dir
=
malloc
(
wcslen
(
home_dir
)
*
sizeof
(
WCHAR
)
+
sizeof
(
L"
\\
.cache"
)
)))
return
NULL
;
lstrcpyW
(
cache_dir
,
home_dir
);
lstrcpyW
(
cache_dir
,
home_dir
);
lstrcatW
(
cache_dir
,
L"
\\
.cache"
);
lstrcatW
(
cache_dir
,
L"
\\
.cache"
);
cache_dir
[
1
]
=
'\\'
;
/* change \??\ into \\?\ */
cache_dir
[
1
]
=
'\\'
;
/* change \??\ into \\?\ */
...
@@ -339,24 +339,24 @@ static WCHAR *get_cache_file_name(BOOL ensure_exists)
...
@@ -339,24 +339,24 @@ static WCHAR *get_cache_file_name(BOOL ensure_exists)
if
(
ensure_exists
&&
!
CreateDirectoryW
(
cache_dir
,
NULL
)
&&
GetLastError
()
!=
ERROR_ALREADY_EXISTS
)
if
(
ensure_exists
&&
!
CreateDirectoryW
(
cache_dir
,
NULL
)
&&
GetLastError
()
!=
ERROR_ALREADY_EXISTS
)
{
{
WARN
(
"%s does not exist and could not be created (%lu)
\n
"
,
debugstr_w
(
cache_dir
),
GetLastError
()
);
WARN
(
"%s does not exist and could not be created (%lu)
\n
"
,
debugstr_w
(
cache_dir
),
GetLastError
()
);
heap_
free
(
cache_dir
);
free
(
cache_dir
);
return
NULL
;
return
NULL
;
}
}
size
=
lstrlenW
(
cache_dir
)
+
ARRAY_SIZE
(
L"
\\
wine"
)
+
lstrlenW
(
addon
->
file_name
)
+
1
;
size
=
lstrlenW
(
cache_dir
)
+
ARRAY_SIZE
(
L"
\\
wine"
)
+
lstrlenW
(
addon
->
file_name
)
+
1
;
if
(
!
(
ret
=
heap_
alloc
(
size
*
sizeof
(
WCHAR
)
)))
if
(
!
(
ret
=
m
alloc
(
size
*
sizeof
(
WCHAR
)
)))
{
{
heap_
free
(
cache_dir
);
free
(
cache_dir
);
return
NULL
;
return
NULL
;
}
}
lstrcpyW
(
ret
,
cache_dir
);
lstrcpyW
(
ret
,
cache_dir
);
lstrcatW
(
ret
,
L"
\\
wine"
);
lstrcatW
(
ret
,
L"
\\
wine"
);
heap_
free
(
cache_dir
);
free
(
cache_dir
);
if
(
ensure_exists
&&
!
CreateDirectoryW
(
ret
,
NULL
)
&&
GetLastError
()
!=
ERROR_ALREADY_EXISTS
)
if
(
ensure_exists
&&
!
CreateDirectoryW
(
ret
,
NULL
)
&&
GetLastError
()
!=
ERROR_ALREADY_EXISTS
)
{
{
WARN
(
"%s does not exist and could not be created (%lu)
\n
"
,
debugstr_w
(
ret
),
GetLastError
()
);
WARN
(
"%s does not exist and could not be created (%lu)
\n
"
,
debugstr_w
(
ret
),
GetLastError
()
);
heap_
free
(
ret
);
free
(
ret
);
return
NULL
;
return
NULL
;
}
}
len
=
lstrlenW
(
ret
);
len
=
lstrlenW
(
ret
);
...
@@ -379,12 +379,12 @@ static enum install_res install_from_cache(void)
...
@@ -379,12 +379,12 @@ static enum install_res install_from_cache(void)
if
(
!
sha_check
(
cache_file_name
))
{
if
(
!
sha_check
(
cache_file_name
))
{
WARN
(
"could not validate checksum
\n
"
);
WARN
(
"could not validate checksum
\n
"
);
DeleteFileW
(
cache_file_name
);
DeleteFileW
(
cache_file_name
);
heap_
free
(
cache_file_name
);
free
(
cache_file_name
);
return
INSTALL_NEXT
;
return
INSTALL_NEXT
;
}
}
res
=
install_file
(
cache_file_name
);
res
=
install_file
(
cache_file_name
);
heap_
free
(
cache_file_name
);
free
(
cache_file_name
);
return
res
;
return
res
;
}
}
...
@@ -485,7 +485,7 @@ static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
...
@@ -485,7 +485,7 @@ static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
cache_file_name
=
get_cache_file_name
(
TRUE
);
cache_file_name
=
get_cache_file_name
(
TRUE
);
if
(
cache_file_name
)
{
if
(
cache_file_name
)
{
CopyFileW
(
msi_file
,
cache_file_name
,
FALSE
);
CopyFileW
(
msi_file
,
cache_file_name
,
FALSE
);
heap_
free
(
cache_file_name
);
free
(
cache_file_name
);
}
}
}
else
{
}
else
{
WCHAR
message
[
256
];
WCHAR
message
[
256
];
...
@@ -495,7 +495,7 @@ static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
...
@@ -495,7 +495,7 @@ static HRESULT WINAPI InstallCallback_OnStopBinding(IBindStatusCallback *iface,
}
}
DeleteFileW
(
msi_file
);
DeleteFileW
(
msi_file
);
heap_
free
(
msi_file
);
free
(
msi_file
);
msi_file
=
NULL
;
msi_file
=
NULL
;
EndDialog
(
install_dialog
,
0
);
EndDialog
(
install_dialog
,
0
);
...
@@ -515,7 +515,7 @@ static HRESULT WINAPI InstallCallback_OnDataAvailable(IBindStatusCallback *iface
...
@@ -515,7 +515,7 @@ static HRESULT WINAPI InstallCallback_OnDataAvailable(IBindStatusCallback *iface
DWORD
dwSize
,
FORMATETC
*
pformatetc
,
STGMEDIUM
*
pstgmed
)
DWORD
dwSize
,
FORMATETC
*
pformatetc
,
STGMEDIUM
*
pstgmed
)
{
{
if
(
!
msi_file
)
{
if
(
!
msi_file
)
{
msi_file
=
heap_strdupW
(
pstgmed
->
u
.
lpszFileName
);
msi_file
=
wcsdup
(
pstgmed
->
u
.
lpszFileName
);
TRACE
(
"got file name %s
\n
"
,
debugstr_w
(
msi_file
));
TRACE
(
"got file name %s
\n
"
,
debugstr_w
(
msi_file
));
}
}
...
@@ -622,15 +622,15 @@ static LPWSTR get_url(void)
...
@@ -622,15 +622,15 @@ static LPWSTR get_url(void)
static
const
WCHAR
httpW
[]
=
{
'h'
,
't'
,
't'
,
'p'
};
static
const
WCHAR
httpW
[]
=
{
'h'
,
't'
,
't'
,
'p'
};
url
=
heap_
alloc
(
size
);
url
=
m
alloc
(
size
);
returned_size
=
size
;
returned_size
=
size
;
hkey
=
open_config_key
();
hkey
=
open_config_key
();
if
(
hkey
)
if
(
hkey
)
{
{
config_key
=
heap_
strdupAtoW
(
addon
->
url_config_key
);
config_key
=
strdupAtoW
(
addon
->
url_config_key
);
res
=
RegQueryValueExW
(
hkey
,
config_key
,
NULL
,
&
type
,
(
LPBYTE
)
url
,
&
returned_size
);
res
=
RegQueryValueExW
(
hkey
,
config_key
,
NULL
,
&
type
,
(
LPBYTE
)
url
,
&
returned_size
);
heap_
free
(
config_key
);
free
(
config_key
);
RegCloseKey
(
hkey
);
RegCloseKey
(
hkey
);
if
(
res
==
ERROR_SUCCESS
&&
type
==
REG_SZ
)
goto
found
;
if
(
res
==
ERROR_SUCCESS
&&
type
==
REG_SZ
)
goto
found
;
}
}
...
@@ -684,7 +684,7 @@ static void run_winebrowser(const WCHAR *url)
...
@@ -684,7 +684,7 @@ static void run_winebrowser(const WCHAR *url)
lstrcpyW
(
app
+
len
,
L"
\\
winebrowser.exe"
);
lstrcpyW
(
app
+
len
,
L"
\\
winebrowser.exe"
);
len
+=
ARRAY_SIZE
(
L"
\\
winebrowser.exe"
)
-
1
;
len
+=
ARRAY_SIZE
(
L"
\\
winebrowser.exe"
)
-
1
;
args
=
heap_alloc
((
len
+
1
+
url_len
)
*
sizeof
(
WCHAR
));
args
=
malloc
((
len
+
1
+
url_len
)
*
sizeof
(
WCHAR
));
if
(
!
args
)
if
(
!
args
)
return
;
return
;
...
@@ -697,7 +697,7 @@ static void run_winebrowser(const WCHAR *url)
...
@@ -697,7 +697,7 @@ static void run_winebrowser(const WCHAR *url)
memset
(
&
si
,
0
,
sizeof
(
si
));
memset
(
&
si
,
0
,
sizeof
(
si
));
si
.
cb
=
sizeof
(
si
);
si
.
cb
=
sizeof
(
si
);
ret
=
CreateProcessW
(
app
,
args
,
NULL
,
NULL
,
FALSE
,
DETACHED_PROCESS
,
NULL
,
NULL
,
&
si
,
&
pi
);
ret
=
CreateProcessW
(
app
,
args
,
NULL
,
NULL
,
FALSE
,
DETACHED_PROCESS
,
NULL
,
NULL
,
&
si
,
&
pi
);
heap_
free
(
args
);
free
(
args
);
if
(
ret
)
{
if
(
ret
)
{
CloseHandle
(
pi
.
hThread
);
CloseHandle
(
pi
.
hThread
);
CloseHandle
(
pi
.
hProcess
);
CloseHandle
(
pi
.
hProcess
);
...
@@ -766,7 +766,7 @@ BOOL install_addon(addon_t addon_type)
...
@@ -766,7 +766,7 @@ BOOL install_addon(addon_t addon_type)
&&
(
url
=
get_url
()))
&&
(
url
=
get_url
()))
DialogBoxW
(
hInst
,
addon
->
dialog_template
,
0
,
installer_proc
);
DialogBoxW
(
hInst
,
addon
->
dialog_template
,
0
,
installer_proc
);
heap_
free
(
url
);
free
(
url
);
url
=
NULL
;
url
=
NULL
;
return
TRUE
;
return
TRUE
;
}
}
dlls/appwiz.cpl/appwiz.h
View file @
d34d0c10
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
*/
#include "wine/heap.h"
#include "winnls.h"
#include "winnls.h"
typedef
enum
{
typedef
enum
{
...
@@ -28,23 +27,7 @@ BOOL install_addon(addon_t) DECLSPEC_HIDDEN;
...
@@ -28,23 +27,7 @@ BOOL install_addon(addon_t) DECLSPEC_HIDDEN;
extern
HINSTANCE
hInst
DECLSPEC_HIDDEN
;
extern
HINSTANCE
hInst
DECLSPEC_HIDDEN
;
static
inline
WCHAR
*
heap_strdupW
(
const
WCHAR
*
str
)
static
inline
WCHAR
*
strdupAtoW
(
const
char
*
str
)
{
WCHAR
*
ret
;
if
(
str
)
{
size_t
size
=
lstrlenW
(
str
)
+
1
;
ret
=
heap_alloc
(
size
*
sizeof
(
WCHAR
));
if
(
ret
)
memcpy
(
ret
,
str
,
size
*
sizeof
(
WCHAR
));
}
else
{
ret
=
NULL
;
}
return
ret
;
}
static
inline
WCHAR
*
heap_strdupAtoW
(
const
char
*
str
)
{
{
WCHAR
*
ret
=
NULL
;
WCHAR
*
ret
=
NULL
;
...
@@ -52,7 +35,7 @@ static inline WCHAR *heap_strdupAtoW(const char *str)
...
@@ -52,7 +35,7 @@ static inline WCHAR *heap_strdupAtoW(const char *str)
size_t
len
;
size_t
len
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
ret
=
heap_alloc
(
len
*
sizeof
(
WCHAR
));
ret
=
malloc
(
len
*
sizeof
(
WCHAR
));
if
(
ret
)
if
(
ret
)
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
);
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment