Index: generic/tclConfig.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclConfig.c,v
retrieving revision 1.17
diff -u -r1.17 tclConfig.c
--- generic/tclConfig.c	20 Nov 2007 10:59:09 -0000	1.17
+++ generic/tclConfig.c	28 Nov 2007 18:14:51 -0000
@@ -28,6 +28,17 @@
 #define ASSOC_KEY	"tclPackageAboutDict"
 
 /*
+ * A ClientData struct for the QueryConfig command.  Store the two bits
+ * of data we need; the package name for which we store a config dict,
+ * and the (Tcl_Interp *) in which it is stored.
+ */
+
+typedef struct QCCD {
+    Tcl_Obj *pkg;
+    Tcl_Interp *interp;
+} QCCD;
+
+/*
  * Static functions in this file:
  */
 
@@ -66,12 +77,14 @@
     CONST char *valEncoding)	/* Name of the encoding used to store the
 				 * configuration values, ASCII, thus UTF-8. */
 {
-    Tcl_Obj *pDB, *pkg, *pkgDict;
+    Tcl_Obj *pDB, *pkgDict;
     Tcl_DString cmdName;
     Tcl_Config *cfg;
     Tcl_Encoding venc = Tcl_GetEncoding(NULL, valEncoding);
+    QCCD *cdPtr = (QCCD *)ckalloc(sizeof(QCCD));
 
-    pkg = Tcl_NewStringObj(pkgName, -1);
+    cdPtr->interp = interp;
+    cdPtr->pkg = Tcl_NewStringObj(pkgName, -1);
 
     /*
      * Phase I: Adding the provided information to the internal database of
@@ -86,7 +99,7 @@
      * Note, the created command will have a reference through its clientdata.
      */
 
-    Tcl_IncrRefCount(pkg);
+    Tcl_IncrRefCount(cdPtr->pkg);
 
     /*
      * For venc == NULL aka bogus encoding we skip the step setting up the
@@ -100,7 +113,7 @@
 
 	pDB = GetConfigDict(interp);
 
-	if (Tcl_DictObjGet(interp, pDB, pkg, &pkgDict) != TCL_OK
+	if (Tcl_DictObjGet(interp, pDB, cdPtr->pkg, &pkgDict) != TCL_OK
 	    || (pkgDict == NULL)) {
 	    pkgDict = Tcl_NewDictObj();
 	} else if (Tcl_IsShared(pkgDict)) {
@@ -136,7 +149,7 @@
 	 * Write the changes back into the overall database.
 	 */
 
-	Tcl_DictObjPut(interp, pDB, pkg, pkgDict);
+	Tcl_DictObjPut(interp, pDB, cdPtr->pkg, pkgDict);
     }
 
     /*
@@ -166,7 +179,7 @@
     Tcl_DStringAppend(&cmdName, "::pkgconfig", -1);
 
     if (Tcl_CreateObjCommand(interp, Tcl_DStringValue(&cmdName),
-	    QueryConfigObjCmd, (ClientData) pkg, QueryConfigDelete) == NULL) {
+	    QueryConfigObjCmd, (ClientData) cdPtr, QueryConfigDelete) == NULL) {
         Tcl_Panic("%s: %s", "Tcl_RegisterConfig",
 		"Unable to create query command for package configuration");
     }
@@ -198,7 +211,8 @@
     int objc,
     struct Tcl_Obj *CONST *objv)
 {
-    Tcl_Obj *pkgName = (Tcl_Obj *) clientData;
+    QCCD *cdPtr = (QCCD *) clientData;
+    Tcl_Obj *pkgName = cdPtr->pkg;
     Tcl_Obj *pDB, *pkgDict, *val, *listPtr;
     int n, index;
     static CONST char *subcmdStrings[] = {
@@ -308,9 +322,12 @@
 QueryConfigDelete(
     ClientData clientData)
 {
-    Tcl_Obj *pkgName = (Tcl_Obj *) clientData;
-
+    QCCD *cdPtr = (QCCD *) clientData;
+    Tcl_Obj *pkgName = cdPtr->pkg;
+    Tcl_Obj *pDB = GetConfigDict(cdPtr->interp);
+    Tcl_DictObjRemove(NULL, pDB, pkgName);
     Tcl_DecrRefCount(pkgName);
+    ckfree((char *)cdPtr);
 }
 
 /*
