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
1c91d545
Commit
1c91d545
authored
Feb 18, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcrt: Don't try to duplicate invalid handles. Don't reset std handles if we didn't set them.
parent
64ae0000
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
15 deletions
+27
-15
file.c
dlls/msvcrt/file.c
+27
-15
No files found.
dlls/msvcrt/file.c
View file @
1c91d545
...
...
@@ -168,7 +168,10 @@ static HANDLE msvcrt_fdtoh(int fd)
/* INTERNAL: free a file entry fd */
static
void
msvcrt_free_fd
(
int
fd
)
{
HANDLE
old_handle
;
LOCK_FILES
();
old_handle
=
MSVCRT_fdesc
[
fd
].
handle
;
MSVCRT_fdesc
[
fd
].
handle
=
INVALID_HANDLE_VALUE
;
MSVCRT_fdesc
[
fd
].
wxflag
=
0
;
TRACE
(
":fd (%d) freed
\n
"
,
fd
);
...
...
@@ -176,9 +179,15 @@ static void msvcrt_free_fd(int fd)
{
switch
(
fd
)
{
case
0
:
SetStdHandle
(
STD_INPUT_HANDLE
,
NULL
);
break
;
case
1
:
SetStdHandle
(
STD_OUTPUT_HANDLE
,
NULL
);
break
;
case
2
:
SetStdHandle
(
STD_ERROR_HANDLE
,
NULL
);
break
;
case
0
:
if
(
GetStdHandle
(
STD_INPUT_HANDLE
)
==
old_handle
)
SetStdHandle
(
STD_INPUT_HANDLE
,
0
);
break
;
case
1
:
if
(
GetStdHandle
(
STD_OUTPUT_HANDLE
)
==
old_handle
)
SetStdHandle
(
STD_OUTPUT_HANDLE
,
0
);
break
;
case
2
:
if
(
GetStdHandle
(
STD_ERROR_HANDLE
)
==
old_handle
)
SetStdHandle
(
STD_ERROR_HANDLE
,
0
);
break
;
}
}
else
...
...
@@ -361,24 +370,27 @@ void msvcrt_init_io(void)
if
(
!
(
MSVCRT_fdesc
[
0
].
wxflag
&
WX_OPEN
)
||
MSVCRT_fdesc
[
0
].
handle
==
INVALID_HANDLE_VALUE
)
{
DuplicateHandle
(
GetCurrentProcess
(),
GetStdHandle
(
STD_INPUT_HANDLE
),
GetCurrentProcess
(),
&
MSVCRT_fdesc
[
0
].
handle
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
MSVCRT_fdesc
[
0
].
wxflag
=
WX_OPEN
|
WX_TEXT
;
HANDLE
std
=
GetStdHandle
(
STD_INPUT_HANDLE
);
if
(
std
!=
INVALID_HANDLE_VALUE
&&
DuplicateHandle
(
GetCurrentProcess
(),
std
,
GetCurrentProcess
(),
&
MSVCRT_fdesc
[
0
].
handle
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
))
MSVCRT_fdesc
[
0
].
wxflag
=
WX_OPEN
|
WX_TEXT
;
}
if
(
!
(
MSVCRT_fdesc
[
1
].
wxflag
&
WX_OPEN
)
||
MSVCRT_fdesc
[
1
].
handle
==
INVALID_HANDLE_VALUE
)
{
DuplicateHandle
(
GetCurrentProcess
(),
GetStdHandle
(
STD_OUTPUT_HANDLE
),
GetCurrentProcess
(),
&
MSVCRT_fdesc
[
1
].
handle
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
MSVCRT_fdesc
[
1
].
wxflag
=
WX_OPEN
|
WX_TEXT
;
HANDLE
std
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
if
(
std
!=
INVALID_HANDLE_VALUE
&&
DuplicateHandle
(
GetCurrentProcess
(),
std
,
GetCurrentProcess
(),
&
MSVCRT_fdesc
[
1
].
handle
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
))
MSVCRT_fdesc
[
1
].
wxflag
=
WX_OPEN
|
WX_TEXT
;
}
if
(
!
(
MSVCRT_fdesc
[
2
].
wxflag
&
WX_OPEN
)
||
MSVCRT_fdesc
[
2
].
handle
==
INVALID_HANDLE_VALUE
)
{
DuplicateHandle
(
GetCurrentProcess
(),
GetStdHandle
(
STD_ERROR_HANDLE
),
GetCurrentProcess
(),
&
MSVCRT_fdesc
[
2
].
handle
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
);
MSVCRT_fdesc
[
2
].
wxflag
=
WX_OPEN
|
WX_TEXT
;
HANDLE
std
=
GetStdHandle
(
STD_ERROR_HANDLE
);
if
(
std
!=
INVALID_HANDLE_VALUE
&&
DuplicateHandle
(
GetCurrentProcess
(),
std
,
GetCurrentProcess
(),
&
MSVCRT_fdesc
[
2
].
handle
,
0
,
TRUE
,
DUPLICATE_SAME_ACCESS
))
MSVCRT_fdesc
[
2
].
wxflag
=
WX_OPEN
|
WX_TEXT
;
}
TRACE
(
":handles (%p)(%p)(%p)
\n
"
,
MSVCRT_fdesc
[
0
].
handle
,
...
...
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