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.