wrowe 02/02/12 18:28:56
Modified: file_io/win32 filedup.c
Log:
Outch. Compare the appropriate file handle! Then close the target if
it is valid, in any case.
Revision Changes Path
1.43 +7 -6 apr/file_io/win32/filedup.c
Index: filedup.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/filedup.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- filedup.c 12 Feb 2002 01:28:17 -0000 1.42
+++ filedup.c 13 Feb 2002 02:28:56 -0000 1.43
@@ -106,13 +106,13 @@
* 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,10 +133,11 @@
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;