summaryrefslogtreecommitdiff
path: root/file_io/win32/filedup.c
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2002-02-13 02:28:56 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2002-02-13 02:28:56 +0000
commite20f3de125de304361c70de38e996193754b6399 (patch)
tree025ab6a93f6597a116febc10ee1c83df03caddac /file_io/win32/filedup.c
parentc2192d26808ac91d2706a4debae327256ca6f78c (diff)
downloadapr-e20f3de125de304361c70de38e996193754b6399.tar.gz
Outch. Compare the appropriate file handle! Then close the target if
it is valid, in any case. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@62974 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/win32/filedup.c')
-rw-r--r--file_io/win32/filedup.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/file_io/win32/filedup.c b/file_io/win32/filedup.c
index e962bc0af..a5ef11c74 100644
--- a/file_io/win32/filedup.c
+++ b/file_io/win32/filedup.c
@@ -106,13 +106,13 @@ APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file,
* and close and replace other handles with duped handles.
* The os_handle will change, however.
*/
- if (old_file->filehand == GetStdHandle(STD_ERROR_HANDLE)) {
+ if (new_file->filehand == GetStdHandle(STD_ERROR_HANDLE)) {
stdhandle = STD_ERROR_HANDLE;
}
- else if (old_file->filehand == GetStdHandle(STD_OUTPUT_HANDLE)) {
+ else if (new_file->filehand == GetStdHandle(STD_OUTPUT_HANDLE)) {
stdhandle = STD_OUTPUT_HANDLE;
}
- else if (old_file->filehand == GetStdHandle(STD_INPUT_HANDLE)) {
+ else if (new_file->filehand == GetStdHandle(STD_INPUT_HANDLE)) {
stdhandle = STD_INPUT_HANDLE;
}
@@ -133,12 +133,13 @@ APR_DECLARE(apr_status_t) apr_file_dup2(apr_file_t *new_file,
FALSE, DUPLICATE_SAME_ACCESS)) {
return apr_get_os_error();
}
- if (new_file->filehand) {
- CloseHandle(new_file->filehand);
- }
newflags = old_file->flags & ~APR_INHERIT;
}
+ if (new_file->filehand && (new_file->filehand != INVALID_HANDLE_VALUE)) {
+ CloseHandle(new_file->filehand);
+ }
+
new_file->flags = newflags;
new_file->filehand = newhand;
new_file->fname = apr_pstrdup(new_file->cntxt, old_file->fname);