Closed Bug 286250 Opened 20 years ago Closed 20 years ago

null pointer exception thrown

Categories

(Rhino Graveyard :: Core, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: gilles.barnier, Assigned: igor)

Details

User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)
Build Identifier: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)

      While using the Rhino 1.6R1 javascript engine, we encountered a situation 
where a null pointer exception was thrown.

      The stack trace indicated that the exception was raised from 
org.mozilla.javascript.ClassCache, in the get function.

      

      Here is the modification that we suggest:

 

          public static ClassCache get(Scriptable scope)

          {

                    //  CHANGE BEGIN

              // Avoid NullPointerException being thrown from 
ScriptableObject.getTopLevelScope(scope) 

                    // in case of null scope

              if (scope==null)

                        return new ClassCache();

              // CHANGE END

                    ClassCache cache;

              cache = (ClassCache)ScriptableObject.getTopScopeValue(scope, 
AKEY);

              if (cache == null) {

                  // XXX warn somehow about wrong cache usage ?

                        cache = new ClassCache();

              }

        return cache;

      }



Reproducible: Always




The attached code is submitted by VERITAS under the MIT license, which is 
reproduced below.

 

The MIT License

Copyright (c) 2005 VERITAS Operating Company 

 

Permission is hereby granted, free of charge, to any person obtaining a copy of 
this software and associated documentation files (the "Software"), to deal in 
the Software without restriction, including without limitation the rights to 
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
of the Software, and to permit persons to whom the Software is furnished to do 
so, subject to the following conditions:

 

The above copyright notice and this permission notice shall be included in all 
copies or substantial portions of the Software.

 

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
NullPointerException indicates most likely about incorrect scope chain setup
since the scope initialized with initStandardObjects is not reachable.

So the question is what is the scope chain here?
Marking as invalid: can not reproduce with normal usage.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.