Skip to content
Tcl Source Code View Ticket
Login

View Ticket

bug in Tcl_DeleteTrace function

Closed / Accepted568123ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-06-12 17:29:49
Here's the patch:

Index: tclBasic.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclBasic.c,v
retrieving revision 1.58
diff -c -r1.58 tclBasic.c
*** tclBasic.c  11 Jun 2002 15:42:19 -0000      1.58
--- tclBasic.c  12 Jun 2002 17:19:37 -0000
***************
*** 4970,4976 ****
      while ( (*tracePtr2) != NULL && (*tracePtr2) != tracePtr ) {
        tracePtr2 = &((*tracePtr2)->nextPtr);
      }
!     if ( tracePtr2 == NULL ) {
        return;
      }
      (*tracePtr2) = (*tracePtr2)->nextPtr;
--- 4970,4976 ----
      while ( (*tracePtr2) != NULL && (*tracePtr2) != tracePtr ) {
        tracePtr2 = &((*tracePtr2)->nextPtr);
      }
!     if ( *tracePtr2 == NULL ) {
        return;
      }
      (*tracePtr2) = (*tracePtr2)->nextPtr;

If you examine the code carefully, tracePtr2 can never be NULL because
it is assigned the address of (*tracePtr2)->nextPtr in the while loop.
On the other hand, it is possible for *tracePtr2 to be NULL (this is also
one of the conditions in while loop). Hence the if condition should check
for *tracePtr2 == NULL instead of tracePtr2 == NULL, otherwise the
following line "(*tracePtr2) = ..." can give segmentation fault.
msoferplain2002-06-13 02:36:15
Logged In: YES 
user_id=148712

Done, thanks.
msofer Ticket [568123ffff]: 3 changes [History diff]2002-06-13 02:40:58
Log in (anonymous is fine) to add a comment.