[Xotcl] Re: new doesnt check for existing object handle.

Gustaf Neumann neumann at wu-wien.ac.at
Mon Apr 18 10:47:43 CEST 2005


Ben Thomasson schrieb:

>Hi Gustaf,
>
>Have you fixed or considered fixing this issue?  
>
Hi Ben,

we have discussed this here, but we have not released any code in this 
direction yet.
The included patch will be in 1.3.7 and prevents overwriting of objects 
through new.

   cd xotcl-1.3.6
   patch -p0 < /tmp/new-patch

best regards
-gustaf
-------------- next part --------------
--- generic/xotcl.c-1.3.6	Mon Apr 18 10:37:42 2005
+++ generic/xotcl.c	Mon Apr 18 10:27:57 2005
@@ -8874,7 +8902,7 @@
 #if REFCOUNTED
     isrefcount = 0, 
 #endif
-    i;
+    i, prefixLength;
   Tcl_DString dFullname, *dsPtr = &dFullname;
   XOTclStringIncrStruct *iss = &RUNTIME_STATE(in)->iss;
 
@@ -8906,8 +8934,16 @@
   } else {
     Tcl_DStringAppend(dsPtr, "::xotcl::__#", 12);
   }
-  (void)XOTclStringIncr(iss);
-  Tcl_DStringAppend(dsPtr, iss->start, iss->length);
+  prefixLength = dsPtr->length;
+
+  while (1) {
+    (void)XOTclStringIncr(iss);
+    Tcl_DStringAppend(dsPtr, iss->start, iss->length);
+    if (!Tcl_FindCommand(in, Tcl_DStringValue(dsPtr), NULL, 0)) {
+      break;
+    }
+    Tcl_DStringSetLength(dsPtr, prefixLength);
+  }
 
   fullname = Tcl_NewStringObj(Tcl_DStringValue(dsPtr), Tcl_DStringLength(dsPtr));
 


More information about the Xotcl mailing list