Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-10-09
09:20 • Closed ticket [1564677fff]: possible NULL deref in Tcl_DeleteEvents plus 6 o... artifact: 58d12305ee user: sf-robot
2006-09-25
07:09 • Pending ticket [1564677fff]. artifact: 84c3fc6366 user: dkf
06:02 • Ticket [1564677fff]: 4 changes artifact: d0befb7cd7 user: jenglish
05:58 • Ticket [1564677fff]: 4 changes artifact: a3fe039006 user: nobody
2006-09-24
19:28 • New ticket [1564677fff]. artifact: 2a38ece3b0 user: msofer

possible NULL deref in Tcl_DeleteEvents

Closed / Fixed1564677fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-09-24 19:28:35
Coverity's bug #10 complains that the line 
   prevPtr->nextPtr = evPtr->nextPtr;
in Tcl_DeleteEvents might be dereferencing a NULL prevPtr. 

At first sight I can not see why that would be wrong.
Is this a bug?
nobodyplain2006-09-25 05:58:22
Logged In: NO 

The outermost for (;;) loop has the invariant:

   (tsdPtr->firstEventPtr == evPtr) <==> (prevPtr == NULL)

Replacing the test 'if (tsdPtr->firstEventPtr == evPtr)'
with the equivalent 'if (prevPtr == NULL)' ought to fix the
warning since the assignment to 'prevPtr->nextPtr' is in the
'else' clause.  Or perhaps even better:

    if (prevPtr != NULL) {
        prevPtr->nextPtr = evPtr->nextPtr;
    } else {
        tsdPtr->firstEventPtr = evPtr->nextPtr;
    }
jenglishplain2006-09-25 06:02:18
Logged In: YES 
user_id=68433

(last comment was from me -- sorry, forgot to log in first
("Remember me" seems to have no effect...))
dkfplain2006-09-25 07:09:54
Logged In: YES 
user_id=79902

The problem is that demonstrating that the pointer is
non-NULL is significantly tricky; it relies on higher order
properties (and could theoretically be messed up by
maintenance). "Fixed" in HEAD by replacing the offending
line with:

if (prevPtr == NULL) {
    Tcl_Panic("badly connected event list");
} else {
    prevPtr->nextPtr = evPtr->nextPtr;
}

Let me know if a backport is needed.
sf-robotplain2006-10-09 09:20:08
Logged In: YES 
user_id=1312539

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.