[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] otcl instvar in global :: scope
Invoking instvar in global scope causes both ns and otclsh to
segfault. There's small patch below that detects the problem and
reports an error; seemed easier than adding support for an undesirable
feature.
% Class Bagel
%
% Bagel instproc init {} {
% $self set diameter 5cm
% }
%
% Bagel motherOfAllBagels
% motherOfAllBagels instvar diameter
Segmentation fault (core dumped)
--- otcl.c.orig Sun Jun 18 22:22:18 2000 +++ otcl.c Sun Jun 18
22:31:26 2000 @@ -1426,10 +1426,11 @@
OTclOInstVarOne(OTclObject* obj, Tcl_Interp *in, char *frameName, char *varName
, char *localName, int flags)
{
Interp* iPtr = (Interp*)in;
- CallFrame* saved = iPtr->varFramePtr->callerVarPtr;
- int level = iPtr->varFramePtr->level;
int result = TCL_ERROR;
+ if (iPtr->varFramePtr) {
+ CallFrame* saved = iPtr->varFramePtr->callerVarPtr;
+ int level = iPtr->varFramePtr->level;
/*
* Fake things as if the caller's stack frame is just over
* the object, then use UpVar to suck the object's variable
@@ -1440,6 +1441,9 @@
result = Tcl_UpVar(in, frameName, varName, localName, flags);
iPtr->varFramePtr->callerVarPtr = saved;
iPtr->varFramePtr->level = level;
+ } else {
+ Tcl_SetResult(in, "no instvar in global :: scope", TCL_STATIC);
+ }
return result;
}
cheers
- Orion.
PS, pointer on http://www.isi.edu/nsnam/ns/ns-lists.html to list
archives wants redirecting to isi.