Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
57927858
Commit
57927858
authored
Dec 07, 2022
by
Alex Henrie
Committed by
Alexandre Julliard
Dec 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Use standard C functions for memory allocation.
parent
702b92ad
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
67 deletions
+66
-67
batch.c
programs/cmd/batch.c
+8
-8
builtins.c
programs/cmd/builtins.c
+0
-0
directory.c
programs/cmd/directory.c
+22
-22
wcmd.h
programs/cmd/wcmd.h
+3
-4
wcmdmain.c
programs/cmd/wcmdmain.c
+33
-33
No files found.
programs/cmd/batch.c
View file @
57927858
...
@@ -68,7 +68,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
...
@@ -68,7 +68,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
prev_context
=
context
;
prev_context
=
context
;
context
=
LocalAlloc
(
LMEM_FIXED
,
sizeof
(
BATCH_CONTEXT
));
context
=
LocalAlloc
(
LMEM_FIXED
,
sizeof
(
BATCH_CONTEXT
));
context
->
h
=
h
;
context
->
h
=
h
;
context
->
batchfileW
=
heap_
strdupW
(
file
);
context
->
batchfileW
=
x
strdupW
(
file
);
context
->
command
=
command
;
context
->
command
=
command
;
memset
(
context
->
shift_count
,
0x00
,
sizeof
(
context
->
shift_count
));
memset
(
context
->
shift_count
,
0x00
,
sizeof
(
context
->
shift_count
));
context
->
prev_context
=
prev_context
;
context
->
prev_context
=
prev_context
;
...
@@ -110,8 +110,8 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
...
@@ -110,8 +110,8 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
* to the caller's caller.
* to the caller's caller.
*/
*/
heap_
free
(
context
->
batchfileW
);
free
(
context
->
batchfileW
);
LocalFree
(
context
);
LocalFree
(
context
);
if
((
prev_context
!=
NULL
)
&&
(
!
called
))
{
if
((
prev_context
!=
NULL
)
&&
(
!
called
))
{
WINE_TRACE
(
"Batch completed, but was not 'called' so skipping outer batch too
\n
"
);
WINE_TRACE
(
"Batch completed, but was not 'called' so skipping outer batch too
\n
"
);
prev_context
->
skip_rest
=
TRUE
;
prev_context
->
skip_rest
=
TRUE
;
...
@@ -256,7 +256,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
...
@@ -256,7 +256,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
const
char
*
p
;
const
char
*
p
;
cp
=
GetOEMCP
();
cp
=
GetOEMCP
();
bufA
=
heap_
xalloc
(
noChars
);
bufA
=
xalloc
(
noChars
);
/* Save current file position */
/* Save current file position */
filepos
.
QuadPart
=
0
;
filepos
.
QuadPart
=
0
;
...
@@ -264,7 +264,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
...
@@ -264,7 +264,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
status
=
ReadFile
(
h
,
bufA
,
noChars
,
&
charsRead
,
NULL
);
status
=
ReadFile
(
h
,
bufA
,
noChars
,
&
charsRead
,
NULL
);
if
(
!
status
||
charsRead
==
0
)
{
if
(
!
status
||
charsRead
==
0
)
{
heap_
free
(
bufA
);
free
(
bufA
);
return
NULL
;
return
NULL
;
}
}
...
@@ -279,7 +279,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
...
@@ -279,7 +279,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
SetFilePointerEx
(
h
,
filepos
,
NULL
,
FILE_BEGIN
);
SetFilePointerEx
(
h
,
filepos
,
NULL
,
FILE_BEGIN
);
i
=
MultiByteToWideChar
(
cp
,
0
,
bufA
,
p
-
bufA
,
buf
,
noChars
);
i
=
MultiByteToWideChar
(
cp
,
0
,
bufA
,
p
-
bufA
,
buf
,
noChars
);
heap_
free
(
bufA
);
free
(
bufA
);
}
}
else
{
else
{
if
(
!
charsRead
)
return
NULL
;
if
(
!
charsRead
)
return
NULL
;
...
@@ -454,11 +454,11 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
...
@@ -454,11 +454,11 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
size
=
GetEnvironmentVariableW
(
env
,
NULL
,
0
);
size
=
GetEnvironmentVariableW
(
env
,
NULL
,
0
);
if
(
size
>
0
)
{
if
(
size
>
0
)
{
WCHAR
*
fullpath
=
heap_x
alloc
(
size
*
sizeof
(
WCHAR
));
WCHAR
*
fullpath
=
m
alloc
(
size
*
sizeof
(
WCHAR
));
if
(
!
fullpath
||
(
GetEnvironmentVariableW
(
env
,
fullpath
,
size
)
==
0
)
||
if
(
!
fullpath
||
(
GetEnvironmentVariableW
(
env
,
fullpath
,
size
)
==
0
)
||
(
SearchPathW
(
fullpath
,
outputparam
,
NULL
,
MAX_PATH
,
outputparam
,
NULL
)
==
0
))
(
SearchPathW
(
fullpath
,
outputparam
,
NULL
,
MAX_PATH
,
outputparam
,
NULL
)
==
0
))
size
=
0
;
size
=
0
;
heap_
free
(
fullpath
);
free
(
fullpath
);
}
}
if
(
!
size
)
{
if
(
!
size
)
{
...
...
programs/cmd/builtins.c
View file @
57927858
This diff is collapsed.
Click to expand it.
programs/cmd/directory.c
View file @
57927858
...
@@ -182,18 +182,18 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
...
@@ -182,18 +182,18 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
ULONG
domainLen
=
MAXSTRING
;
ULONG
domainLen
=
MAXSTRING
;
SID_NAME_USE
nameuse
;
SID_NAME_USE
nameuse
;
secBuffer
=
heap_
xalloc
(
sizeNeeded
*
sizeof
(
BYTE
));
secBuffer
=
xalloc
(
sizeNeeded
*
sizeof
(
BYTE
));
/* Get the owners security descriptor */
/* Get the owners security descriptor */
if
(
!
GetFileSecurityW
(
filename
,
OWNER_SECURITY_INFORMATION
,
secBuffer
,
if
(
!
GetFileSecurityW
(
filename
,
OWNER_SECURITY_INFORMATION
,
secBuffer
,
sizeNeeded
,
&
sizeNeeded
))
{
sizeNeeded
,
&
sizeNeeded
))
{
heap_
free
(
secBuffer
);
free
(
secBuffer
);
return
;
return
;
}
}
/* Get the SID from the SD */
/* Get the SID from the SD */
if
(
!
GetSecurityDescriptorOwner
(
secBuffer
,
&
pSID
,
&
defaulted
))
{
if
(
!
GetSecurityDescriptorOwner
(
secBuffer
,
&
pSID
,
&
defaulted
))
{
heap_
free
(
secBuffer
);
free
(
secBuffer
);
return
;
return
;
}
}
...
@@ -201,7 +201,7 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
...
@@ -201,7 +201,7 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
if
(
LookupAccountSidW
(
NULL
,
pSID
,
name
,
&
nameLen
,
domain
,
&
domainLen
,
&
nameuse
))
{
if
(
LookupAccountSidW
(
NULL
,
pSID
,
name
,
&
nameLen
,
domain
,
&
domainLen
,
&
nameuse
))
{
swprintf
(
owner
,
ownerlen
,
L"%s%c%s"
,
domain
,
'\\'
,
name
);
swprintf
(
owner
,
ownerlen
,
L"%s%c%s"
,
domain
,
'\\'
,
name
);
}
}
heap_
free
(
secBuffer
);
free
(
secBuffer
);
}
}
return
;
return
;
}
}
...
@@ -242,7 +242,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
...
@@ -242,7 +242,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
same directory. Note issuing a directory header with no contents
same directory. Note issuing a directory header with no contents
mirrors what windows does */
mirrors what windows does */
parms
=
inputparms
;
parms
=
inputparms
;
fd
=
heap_
xalloc
(
sizeof
(
WIN32_FIND_DATAW
));
fd
=
xalloc
(
sizeof
(
WIN32_FIND_DATAW
));
while
(
parms
&&
lstrcmpW
(
inputparms
->
dirName
,
parms
->
dirName
)
==
0
)
{
while
(
parms
&&
lstrcmpW
(
inputparms
->
dirName
,
parms
->
dirName
)
==
0
)
{
concurrentDirs
++
;
concurrentDirs
++
;
...
@@ -267,7 +267,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
...
@@ -267,7 +267,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if
(
tmpLen
>
widest
)
widest
=
tmpLen
;
if
(
tmpLen
>
widest
)
widest
=
tmpLen
;
}
}
fd
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
fd
,(
entry_count
+
1
)
*
sizeof
(
WIN32_FIND_DATAW
));
fd
=
realloc
(
fd
,
(
entry_count
+
1
)
*
sizeof
(
WIN32_FIND_DATAW
));
if
(
fd
==
NULL
)
{
if
(
fd
==
NULL
)
{
FindClose
(
hff
);
FindClose
(
hff
);
WINE_ERR
(
"Out of memory
\n
"
);
WINE_ERR
(
"Out of memory
\n
"
);
...
@@ -431,7 +431,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
...
@@ -431,7 +431,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
}
}
}
}
}
}
heap_
free
(
fd
);
free
(
fd
);
/* When recursing, look in all subdirectories for matches */
/* When recursing, look in all subdirectories for matches */
if
(
recurse
)
{
if
(
recurse
)
{
...
@@ -466,13 +466,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
...
@@ -466,13 +466,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
WINE_TRACE
(
"Recursive, Adding to search list '%s'
\n
"
,
wine_dbgstr_w
(
string
));
WINE_TRACE
(
"Recursive, Adding to search list '%s'
\n
"
,
wine_dbgstr_w
(
string
));
/* Allocate memory, add to list */
/* Allocate memory, add to list */
thisDir
=
heap_
xalloc
(
sizeof
(
DIRECTORY_STACK
));
thisDir
=
xalloc
(
sizeof
(
DIRECTORY_STACK
));
if
(
dirStack
==
NULL
)
dirStack
=
thisDir
;
if
(
dirStack
==
NULL
)
dirStack
=
thisDir
;
if
(
lastEntry
!=
NULL
)
lastEntry
->
next
=
thisDir
;
if
(
lastEntry
!=
NULL
)
lastEntry
->
next
=
thisDir
;
lastEntry
=
thisDir
;
lastEntry
=
thisDir
;
thisDir
->
next
=
NULL
;
thisDir
->
next
=
NULL
;
thisDir
->
dirName
=
heap_
strdupW
(
string
);
thisDir
->
dirName
=
x
strdupW
(
string
);
thisDir
->
fileName
=
heap_
strdupW
(
parms
->
fileName
);
thisDir
->
fileName
=
x
strdupW
(
parms
->
fileName
);
parms
=
parms
->
next
;
parms
=
parms
->
next
;
}
}
}
}
...
@@ -484,9 +484,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
...
@@ -484,9 +484,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
dirStack
=
WCMD_list_directory
(
thisDir
,
1
);
dirStack
=
WCMD_list_directory
(
thisDir
,
1
);
while
(
thisDir
!=
dirStack
)
{
while
(
thisDir
!=
dirStack
)
{
DIRECTORY_STACK
*
tempDir
=
thisDir
->
next
;
DIRECTORY_STACK
*
tempDir
=
thisDir
->
next
;
heap_
free
(
thisDir
->
dirName
);
free
(
thisDir
->
dirName
);
heap_
free
(
thisDir
->
fileName
);
free
(
thisDir
->
fileName
);
heap_
free
(
thisDir
);
free
(
thisDir
);
thisDir
=
tempDir
;
thisDir
=
tempDir
;
}
}
}
}
...
@@ -786,7 +786,7 @@ void WCMD_directory (WCHAR *args)
...
@@ -786,7 +786,7 @@ void WCMD_directory (WCHAR *args)
}
}
WINE_TRACE
(
"Using path '%s'
\n
"
,
wine_dbgstr_w
(
path
));
WINE_TRACE
(
"Using path '%s'
\n
"
,
wine_dbgstr_w
(
path
));
thisEntry
=
heap_
xalloc
(
sizeof
(
DIRECTORY_STACK
));
thisEntry
=
xalloc
(
sizeof
(
DIRECTORY_STACK
));
if
(
fullParms
==
NULL
)
fullParms
=
thisEntry
;
if
(
fullParms
==
NULL
)
fullParms
=
thisEntry
;
if
(
prevEntry
!=
NULL
)
prevEntry
->
next
=
thisEntry
;
if
(
prevEntry
!=
NULL
)
prevEntry
->
next
=
thisEntry
;
prevEntry
=
thisEntry
;
prevEntry
=
thisEntry
;
...
@@ -798,11 +798,11 @@ void WCMD_directory (WCHAR *args)
...
@@ -798,11 +798,11 @@ void WCMD_directory (WCHAR *args)
wine_dbgstr_w
(
drive
),
wine_dbgstr_w
(
dir
),
wine_dbgstr_w
(
drive
),
wine_dbgstr_w
(
dir
),
wine_dbgstr_w
(
fname
),
wine_dbgstr_w
(
ext
));
wine_dbgstr_w
(
fname
),
wine_dbgstr_w
(
ext
));
thisEntry
->
dirName
=
heap_xalloc
(
sizeof
(
WCHAR
)
*
(
lstrlenW
(
drive
)
+
lstrlenW
(
dir
)
+
1
));
thisEntry
->
dirName
=
xalloc
(
sizeof
(
WCHAR
)
*
(
wcslen
(
drive
)
+
wcslen
(
dir
)
+
1
));
lstrcpyW
(
thisEntry
->
dirName
,
drive
);
lstrcpyW
(
thisEntry
->
dirName
,
drive
);
lstrcatW
(
thisEntry
->
dirName
,
dir
);
lstrcatW
(
thisEntry
->
dirName
,
dir
);
thisEntry
->
fileName
=
heap_xalloc
(
sizeof
(
WCHAR
)
*
(
lstrlenW
(
fname
)
+
lstrlenW
(
ext
)
+
1
));
thisEntry
->
fileName
=
xalloc
(
sizeof
(
WCHAR
)
*
(
wcslen
(
fname
)
+
wcslen
(
ext
)
+
1
));
lstrcpyW
(
thisEntry
->
fileName
,
fname
);
lstrcpyW
(
thisEntry
->
fileName
,
fname
);
lstrcatW
(
thisEntry
->
fileName
,
ext
);
lstrcatW
(
thisEntry
->
fileName
,
ext
);
...
@@ -812,10 +812,10 @@ void WCMD_directory (WCHAR *args)
...
@@ -812,10 +812,10 @@ void WCMD_directory (WCHAR *args)
/* If just 'dir' entered, a '*' parameter is assumed */
/* If just 'dir' entered, a '*' parameter is assumed */
if
(
fullParms
==
NULL
)
{
if
(
fullParms
==
NULL
)
{
WINE_TRACE
(
"Inserting default '*'
\n
"
);
WINE_TRACE
(
"Inserting default '*'
\n
"
);
fullParms
=
heap_
xalloc
(
sizeof
(
DIRECTORY_STACK
));
fullParms
=
xalloc
(
sizeof
(
DIRECTORY_STACK
));
fullParms
->
next
=
NULL
;
fullParms
->
next
=
NULL
;
fullParms
->
dirName
=
heap_
strdupW
(
cwd
);
fullParms
->
dirName
=
x
strdupW
(
cwd
);
fullParms
->
fileName
=
heap_
strdupW
(
L"*"
);
fullParms
->
fileName
=
x
strdupW
(
L"*"
);
}
}
lastDrive
=
'?'
;
lastDrive
=
'?'
;
...
@@ -872,8 +872,8 @@ exit:
...
@@ -872,8 +872,8 @@ exit:
while
(
fullParms
!=
NULL
)
{
while
(
fullParms
!=
NULL
)
{
prevEntry
=
fullParms
;
prevEntry
=
fullParms
;
fullParms
=
prevEntry
->
next
;
fullParms
=
prevEntry
->
next
;
heap_
free
(
prevEntry
->
dirName
);
free
(
prevEntry
->
dirName
);
heap_
free
(
prevEntry
->
fileName
);
free
(
prevEntry
->
fileName
);
heap_
free
(
prevEntry
);
free
(
prevEntry
);
}
}
}
}
programs/cmd/wcmd.h
View file @
57927858
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <stdio.h>
#include <ctype.h>
#include <ctype.h>
#include <wchar.h>
#include <wchar.h>
#include <wine/heap.h>
/* msdn specified max for Win XP */
/* msdn specified max for Win XP */
#define MAXSTRING 8192
#define MAXSTRING 8192
...
@@ -125,9 +124,9 @@ void WCMD_free_commands(CMD_LIST *cmds);
...
@@ -125,9 +124,9 @@ void WCMD_free_commands(CMD_LIST *cmds);
void
WCMD_execute
(
const
WCHAR
*
orig_command
,
const
WCHAR
*
redirects
,
void
WCMD_execute
(
const
WCHAR
*
orig_command
,
const
WCHAR
*
redirects
,
CMD_LIST
**
cmdList
,
BOOL
retrycall
);
CMD_LIST
**
cmdList
,
BOOL
retrycall
);
void
*
heap_xalloc
(
size_t
)
;
void
*
xalloc
(
size_t
)
__WINE_ALLOC_SIZE
(
1
)
__WINE_DEALLOC
(
free
)
__WINE_MALLOC
;
static
inline
WCHAR
*
heap_
strdupW
(
const
WCHAR
*
str
)
static
inline
WCHAR
*
x
strdupW
(
const
WCHAR
*
str
)
{
{
WCHAR
*
ret
=
NULL
;
WCHAR
*
ret
=
NULL
;
...
@@ -135,7 +134,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
...
@@ -135,7 +134,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
size_t
size
;
size_t
size
;
size
=
(
lstrlenW
(
str
)
+
1
)
*
sizeof
(
WCHAR
);
size
=
(
lstrlenW
(
str
)
+
1
)
*
sizeof
(
WCHAR
);
ret
=
heap_
xalloc
(
size
);
ret
=
xalloc
(
size
);
memcpy
(
ret
,
str
,
size
);
memcpy
(
ret
,
str
,
size
);
}
}
...
...
programs/cmd/wcmdmain.c
View file @
57927858
...
@@ -67,7 +67,7 @@ static char *get_file_buffer(void)
...
@@ -67,7 +67,7 @@ static char *get_file_buffer(void)
{
{
static
char
*
output_bufA
=
NULL
;
static
char
*
output_bufA
=
NULL
;
if
(
!
output_bufA
)
if
(
!
output_bufA
)
output_bufA
=
heap_
xalloc
(
MAX_WRITECONSOLE_SIZE
);
output_bufA
=
xalloc
(
MAX_WRITECONSOLE_SIZE
);
return
output_bufA
;
return
output_bufA
;
}
}
...
@@ -423,11 +423,11 @@ static void WCMD_show_prompt (BOOL newLine) {
...
@@ -423,11 +423,11 @@ static void WCMD_show_prompt (BOOL newLine) {
WCMD_output_asis
(
out_string
);
WCMD_output_asis
(
out_string
);
}
}
void
*
heap_
xalloc
(
size_t
size
)
void
*
xalloc
(
size_t
size
)
{
{
void
*
ret
;
void
*
ret
;
ret
=
heap_
alloc
(
size
);
ret
=
m
alloc
(
size
);
if
(
!
ret
)
{
if
(
!
ret
)
{
ERR
(
"Out of memory
\n
"
);
ERR
(
"Out of memory
\n
"
);
ExitProcess
(
1
);
ExitProcess
(
1
);
...
@@ -732,16 +732,16 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
...
@@ -732,16 +732,16 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
WCHAR
*
searchFor
;
WCHAR
*
searchFor
;
if
(
equalspos
==
NULL
)
return
start
+
1
;
if
(
equalspos
==
NULL
)
return
start
+
1
;
s
=
heap_
strdupW
(
endOfVar
+
1
);
s
=
x
strdupW
(
endOfVar
+
1
);
/* Null terminate both strings */
/* Null terminate both strings */
thisVar
[
lstrlenW
(
thisVar
)
-
1
]
=
0x00
;
thisVar
[
lstrlenW
(
thisVar
)
-
1
]
=
0x00
;
*
equalspos
=
0x00
;
*
equalspos
=
0x00
;
/* Since we need to be case insensitive, copy the 2 buffers */
/* Since we need to be case insensitive, copy the 2 buffers */
searchIn
=
heap_
strdupW
(
thisVarContents
);
searchIn
=
x
strdupW
(
thisVarContents
);
CharUpperBuffW
(
searchIn
,
lstrlenW
(
thisVarContents
));
CharUpperBuffW
(
searchIn
,
lstrlenW
(
thisVarContents
));
searchFor
=
heap_strdupW
(
colonpos
+
1
);
searchFor
=
xstrdupW
(
colonpos
+
1
);
CharUpperBuffW
(
searchFor
,
lstrlenW
(
colonpos
+
1
));
CharUpperBuffW
(
searchFor
,
lstrlenW
(
colonpos
+
1
));
/* Handle wildcard case */
/* Handle wildcard case */
...
@@ -779,9 +779,9 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
...
@@ -779,9 +779,9 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
thisVarContents
+
(
lastFound
-
searchIn
));
thisVarContents
+
(
lastFound
-
searchIn
));
lstrcatW
(
outputposn
,
s
);
lstrcatW
(
outputposn
,
s
);
}
}
heap_
free
(
s
);
free
(
s
);
heap_
free
(
searchIn
);
free
(
searchIn
);
heap_
free
(
searchFor
);
free
(
searchFor
);
}
}
return
start
;
return
start
;
}
}
...
@@ -971,7 +971,7 @@ static void init_msvcrt_io_block(STARTUPINFOW* st)
...
@@ -971,7 +971,7 @@ static void init_msvcrt_io_block(STARTUPINFOW* st)
* its new input & output handles)
* its new input & output handles)
*/
*/
sz
=
max
(
sizeof
(
unsigned
)
+
(
sizeof
(
char
)
+
sizeof
(
HANDLE
))
*
3
,
st_p
.
cbReserved2
);
sz
=
max
(
sizeof
(
unsigned
)
+
(
sizeof
(
char
)
+
sizeof
(
HANDLE
))
*
3
,
st_p
.
cbReserved2
);
ptr
=
heap_
xalloc
(
sz
);
ptr
=
xalloc
(
sz
);
flags
=
(
char
*
)(
ptr
+
sizeof
(
unsigned
));
flags
=
(
char
*
)(
ptr
+
sizeof
(
unsigned
));
handles
=
(
HANDLE
*
)(
flags
+
num
*
sizeof
(
char
));
handles
=
(
HANDLE
*
)(
flags
+
num
*
sizeof
(
char
));
...
@@ -1221,7 +1221,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
...
@@ -1221,7 +1221,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
Note: Launching internal wine processes cannot specify a full path to exe */
Note: Launching internal wine processes cannot specify a full path to exe */
status
=
CreateProcessW
(
thisDir
,
status
=
CreateProcessW
(
thisDir
,
command
,
NULL
,
NULL
,
TRUE
,
0
,
NULL
,
NULL
,
&
st
,
&
pe
);
command
,
NULL
,
NULL
,
TRUE
,
0
,
NULL
,
NULL
,
&
st
,
&
pe
);
heap_
free
(
st
.
lpReserved2
);
free
(
st
.
lpReserved2
);
if
((
opt_c
||
opt_k
)
&&
!
opt_s
&&
!
status
if
((
opt_c
||
opt_k
)
&&
!
opt_s
&&
!
status
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
&&
command
[
0
]
==
'\"'
)
{
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
&&
command
[
0
]
==
'\"'
)
{
/* strip first and last quote WCHARacters and try again */
/* strip first and last quote WCHARacters and try again */
...
@@ -1301,12 +1301,12 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
...
@@ -1301,12 +1301,12 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
wine_dbgstr_w
(
command
),
cmdList
);
wine_dbgstr_w
(
command
),
cmdList
);
/* Move copy of the command onto the heap so it can be expanded */
/* Move copy of the command onto the heap so it can be expanded */
new_cmd
=
heap_
xalloc
(
MAXSTRING
*
sizeof
(
WCHAR
));
new_cmd
=
xalloc
(
MAXSTRING
*
sizeof
(
WCHAR
));
lstrcpyW
(
new_cmd
,
command
);
lstrcpyW
(
new_cmd
,
command
);
cmd
=
new_cmd
;
cmd
=
new_cmd
;
/* Move copy of the redirects onto the heap so it can be expanded */
/* Move copy of the redirects onto the heap so it can be expanded */
new_redir
=
heap_
xalloc
(
MAXSTRING
*
sizeof
(
WCHAR
));
new_redir
=
xalloc
(
MAXSTRING
*
sizeof
(
WCHAR
));
redir
=
new_redir
;
redir
=
new_redir
;
/* Strip leading whitespaces, and a '@' if supplied */
/* Strip leading whitespaces, and a '@' if supplied */
...
@@ -1389,8 +1389,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
...
@@ -1389,8 +1389,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
WINE_TRACE
(
"Got directory %s as %s
\n
"
,
wine_dbgstr_w
(
envvar
),
wine_dbgstr_w
(
cmd
));
WINE_TRACE
(
"Got directory %s as %s
\n
"
,
wine_dbgstr_w
(
envvar
),
wine_dbgstr_w
(
cmd
));
status
=
SetCurrentDirectoryW
(
cmd
);
status
=
SetCurrentDirectoryW
(
cmd
);
if
(
!
status
)
WCMD_print_error
();
if
(
!
status
)
WCMD_print_error
();
heap_free
(
cmd
);
free
(
cmd
);
heap_
free
(
new_redir
);
free
(
new_redir
);
return
;
return
;
}
}
...
@@ -1412,8 +1412,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
...
@@ -1412,8 +1412,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
FILE_ATTRIBUTE_NORMAL
|
FILE_FLAG_DELETE_ON_CLOSE
,
NULL
);
FILE_ATTRIBUTE_NORMAL
|
FILE_FLAG_DELETE_ON_CLOSE
,
NULL
);
if
(
h
==
INVALID_HANDLE_VALUE
)
{
if
(
h
==
INVALID_HANDLE_VALUE
)
{
WCMD_print_error
();
WCMD_print_error
();
heap_
free
(
cmd
);
free
(
cmd
);
heap_
free
(
new_redir
);
free
(
new_redir
);
return
;
return
;
}
}
SetStdHandle
(
STD_INPUT_HANDLE
,
h
);
SetStdHandle
(
STD_INPUT_HANDLE
,
h
);
...
@@ -1427,8 +1427,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
...
@@ -1427,8 +1427,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
&
sa
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
&
sa
,
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
h
==
INVALID_HANDLE_VALUE
)
{
if
(
h
==
INVALID_HANDLE_VALUE
)
{
WCMD_print_error
();
WCMD_print_error
();
heap_
free
(
cmd
);
free
(
cmd
);
heap_
free
(
new_redir
);
free
(
new_redir
);
return
;
return
;
}
}
SetStdHandle
(
STD_INPUT_HANDLE
,
h
);
SetStdHandle
(
STD_INPUT_HANDLE
,
h
);
...
@@ -1472,8 +1472,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
...
@@ -1472,8 +1472,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
&
sa
,
creationDisposition
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
&
sa
,
creationDisposition
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
if
(
h
==
INVALID_HANDLE_VALUE
)
{
if
(
h
==
INVALID_HANDLE_VALUE
)
{
WCMD_print_error
();
WCMD_print_error
();
heap_
free
(
cmd
);
free
(
cmd
);
heap_
free
(
new_redir
);
free
(
new_redir
);
return
;
return
;
}
}
if
(
SetFilePointer
(
h
,
0
,
NULL
,
FILE_END
)
==
if
(
SetFilePointer
(
h
,
0
,
NULL
,
FILE_END
)
==
...
@@ -1643,8 +1643,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
...
@@ -1643,8 +1643,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
WCMD_run_program
(
whichcmd
,
FALSE
);
WCMD_run_program
(
whichcmd
,
FALSE
);
echo_mode
=
prev_echo_mode
;
echo_mode
=
prev_echo_mode
;
}
}
heap_
free
(
cmd
);
free
(
cmd
);
heap_
free
(
new_redir
);
free
(
new_redir
);
/* Restore old handles */
/* Restore old handles */
for
(
i
=
0
;
i
<
3
;
i
++
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
{
...
@@ -1705,16 +1705,16 @@ static void WCMD_addCommand(WCHAR *command, int *commandLen,
...
@@ -1705,16 +1705,16 @@ static void WCMD_addCommand(WCHAR *command, int *commandLen,
CMD_LIST
*
thisEntry
=
NULL
;
CMD_LIST
*
thisEntry
=
NULL
;
/* Allocate storage for command */
/* Allocate storage for command */
thisEntry
=
heap_
xalloc
(
sizeof
(
CMD_LIST
));
thisEntry
=
xalloc
(
sizeof
(
CMD_LIST
));
/* Copy in the command */
/* Copy in the command */
if
(
command
)
{
if
(
command
)
{
thisEntry
->
command
=
heap_xalloc
((
*
commandLen
+
1
)
*
sizeof
(
WCHAR
));
thisEntry
->
command
=
xalloc
((
*
commandLen
+
1
)
*
sizeof
(
WCHAR
));
memcpy
(
thisEntry
->
command
,
command
,
*
commandLen
*
sizeof
(
WCHAR
));
memcpy
(
thisEntry
->
command
,
command
,
*
commandLen
*
sizeof
(
WCHAR
));
thisEntry
->
command
[
*
commandLen
]
=
0x00
;
thisEntry
->
command
[
*
commandLen
]
=
0x00
;
/* Copy in the redirects */
/* Copy in the redirects */
thisEntry
->
redirects
=
heap_xalloc
((
*
redirLen
+
1
)
*
sizeof
(
WCHAR
));
thisEntry
->
redirects
=
xalloc
((
*
redirLen
+
1
)
*
sizeof
(
WCHAR
));
memcpy
(
thisEntry
->
redirects
,
redirs
,
*
redirLen
*
sizeof
(
WCHAR
));
memcpy
(
thisEntry
->
redirects
,
redirs
,
*
redirLen
*
sizeof
(
WCHAR
));
thisEntry
->
redirects
[
*
redirLen
]
=
0x00
;
thisEntry
->
redirects
[
*
redirLen
]
=
0x00
;
thisEntry
->
pipeFile
[
0
]
=
0x00
;
thisEntry
->
pipeFile
[
0
]
=
0x00
;
...
@@ -1845,7 +1845,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
...
@@ -1845,7 +1845,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* Allocate working space for a command read from keyboard, file etc */
/* Allocate working space for a command read from keyboard, file etc */
if
(
!
extraSpace
)
if
(
!
extraSpace
)
extraSpace
=
heap_xalloc
((
MAXSTRING
+
1
)
*
sizeof
(
WCHAR
));
extraSpace
=
xalloc
((
MAXSTRING
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
extraSpace
)
if
(
!
extraSpace
)
{
{
WINE_ERR
(
"Could not allocate memory for extraSpace
\n
"
);
WINE_ERR
(
"Could not allocate memory for extraSpace
\n
"
);
...
@@ -2399,9 +2399,9 @@ void WCMD_free_commands(CMD_LIST *cmds) {
...
@@ -2399,9 +2399,9 @@ void WCMD_free_commands(CMD_LIST *cmds) {
while
(
cmds
)
{
while
(
cmds
)
{
CMD_LIST
*
thisCmd
=
cmds
;
CMD_LIST
*
thisCmd
=
cmds
;
cmds
=
cmds
->
nextcommand
;
cmds
=
cmds
->
nextcommand
;
heap_
free
(
thisCmd
->
command
);
free
(
thisCmd
->
command
);
heap_
free
(
thisCmd
->
redirects
);
free
(
thisCmd
->
redirects
);
heap_
free
(
thisCmd
);
free
(
thisCmd
);
}
}
}
}
...
@@ -2516,7 +2516,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
...
@@ -2516,7 +2516,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
WCHAR
*
q1
=
NULL
,
*
q2
=
NULL
,
*
p
;
WCHAR
*
q1
=
NULL
,
*
q2
=
NULL
,
*
p
;
/* Take a copy */
/* Take a copy */
cmd
=
heap_
strdupW
(
arg
);
cmd
=
x
strdupW
(
arg
);
/* opt_s left unflagged if the command starts with and contains exactly
/* opt_s left unflagged if the command starts with and contains exactly
* one quoted string (exactly two quote characters). The quoted string
* one quoted string (exactly two quote characters). The quoted string
...
@@ -2674,7 +2674,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
...
@@ -2674,7 +2674,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
WCMD_free_commands
(
toExecute
);
WCMD_free_commands
(
toExecute
);
toExecute
=
NULL
;
toExecute
=
NULL
;
heap_
free
(
cmd
);
free
(
cmd
);
return
errorlevel
;
return
errorlevel
;
}
}
...
@@ -2754,7 +2754,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
...
@@ -2754,7 +2754,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
WCMD_process_commands
(
toExecute
,
FALSE
,
FALSE
);
WCMD_process_commands
(
toExecute
,
FALSE
,
FALSE
);
WCMD_free_commands
(
toExecute
);
WCMD_free_commands
(
toExecute
);
toExecute
=
NULL
;
toExecute
=
NULL
;
heap_
free
(
cmd
);
free
(
cmd
);
}
}
/*
/*
...
...
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