[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kjs [POSSIBLY UNSAFE]
From: David Faure <faure () kde ! org>
Date: 2003-01-23 21:53:56
[Download RAW message or body]
CVS commit by faure:
Put undeclared vars into the right global object.
M +17 -1 internal.cpp 1.142 [POSSIBLY UNSAFE: printf]
--- kdelibs/kjs/internal.cpp #1.141:1.142
@@ -257,5 +257,21 @@ void Reference2::putValue(ExecState *exe
#endif
if (bs.type() == NullType)
- exec->interpreter()->globalObject().put(exec, propertyName(), w);
+ {
+ // Declare new variable in the right (lexically scoped) global object
+ // which is the last item in the scope chain
+ List chain = exec->context().scopeChain();
+ if ( chain.isEmpty() )
+ fprintf( stderr, "KJS: Reference2::putValue: empty scope chain!\n" );
+ else
+ {
+ ListIterator last = chain.end();
+ --last;
+ Object varObj = Object::dynamicCast( *last );
+ if ( varObj.isValid() )
+ varObj.put(exec, propertyName(), w);
+ else // shouldn't happen
+ fprintf( stderr, "KJS: Reference2::putValue: scope chain contains non-object!\n" );
+ }
+ }
else
static_cast<ObjectImp*>(bs.imp())->put(exec, propertyName(), w);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic