Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: fd8c910d7e509b7f4d69a07bc2067bc55a74b83f
Ticket: 618852ffffffffffffffffffffffffffffffffff
possibly logic error in tclWinChan.c
User & Date: nobody on 2002-10-05 05:09:03
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    While cruising through the Tcl source code, i found 
    this code.
    
    tclWinChan.c starting at line #1023:
    
        default:
    /*
     * The handle is of an unknown type.  
    Test the validity of this OS
     * handle by duplicating it, then closing 
    the dupe.  The Win32 API
     * doesn't provide an IsValidHandle() 
    function, so we have to emulate
     * it here.  This test will not work on a 
    console handle reliably,
     * which is why we can't test every handle 
    that comes into this
     * function in this way.
     */
    
    result = DuplicateHandle
    (GetCurrentProcess(), handle,
    GetCurrentProcess(), 
    &dupedHandle, 0, FALSE,
    DUPLICATE_SAME_ACCESS);
    
    if (result != 0) {
        /* 
         * Unable to make a duplicate. It's 
    definately invalid at this
         * point.
         */
    
        return NULL;
    }
    
    ------------------------
    
    The above code does not appear to be correct.  The 
    DuplicateHandle function returns non-zero to 
    indicate SUCCESS, not failure.  If the intent (??) of 
    the above code is to bail out in case of error, then 
    it is definately not correct.  I believe the correct if 
    statement would check for (result == 0).
    
    I think somebody should take a close look at this 
    logic to make sure I am not confused.  
    
    A cursory search of the Tcl/Tk source trees reveals 
    no other places where DuplicateHandle is being 
    called AND where the caller relies upon it's return 
    code.
    
    ------------------------
    
    From the SDK:
    
    Return Values
    If the function succeeds, the return value is 
    nonzero.
    
    If the function fails, the return value is zero. To get 
    extended error information, call GetLastError. 
    
    ------------------------
    
    JJM
    
    
  4. foundin changed to: "obsolete: 8.4.0"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "None"
  10. title changed to: "possibly logic error in tclWinChan.c"
  11. type changed to: "Bug"