Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-10-23
15:53 • Closed ticket [473875ffff]: nextPtr init in Tk_GetCursorFromData() plus 8 ot... artifact: 8f9ae86a8c user: dkf
02:20 • New ticket [473875ffff]. artifact: 804aa0b9a5 user: nobody

nextPtr init in Tk_GetCursorFromData()

Closed / Invalid473875ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-10-23 02:20:25
Tk_GetCursorFromData() does not initialize nextPtr
field to NULL when allocating a new Tk_Cursor object.
If the allocated memory is not automatically 
initialized, it'll cause a problem later when 
another cursor is allocated from the same data
after this cursor is destroyed. I.e.:

a = Tk_GetCursorFromData(...);
...
Tk_FreeCursor(a);
...
/* b is allocated using the same setup as a */
b = Tk_GetCursorFromData(...); /* seg fault */

This was found with hiertable in blt2.4u.

Solution: apply the following patch to generic/tkCursor.c:

--- tkCursor.c.oldMon Oct 22 19:16:41 2001
+++ tkCursor.cMon Oct 22 18:57:37 2001
@@ -384,6 +384,8 @@
     cursorPtr->objRefCount = 0;
     cursorPtr->idHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorIdTable, 
             (char *) cursorPtr->cursor, &new);
+    /* XXX Set nextPtr to NULL ! */
+    cursorPtr->nextPtr = NULL;
 
     if (!new) {
 panic("cursor already registered in Tk_GetCursorFromData");
dkfplain2001-10-23 15:53:53
Logged In: YES 
user_id=79902

This is a Tk patch, not a Tcl patch.  (I've applied it to Tk
too.)
Log in (anonymous is fine) to add a comment.