gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r10885: Initialize all members of as


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10885: Initialize all members of asMethod, fixing an occasional crash due to
Date: Tue, 19 May 2009 17:55:16 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 10885
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2009-05-19 17:55:16 +0200
message:
  Initialize all members of asMethod, fixing an occasional crash due to
  uninitialized values. This may also fix a bug reported on the mailing list.
modified:
  libcore/asClass.h
  libcore/asMethod.cpp
  libcore/vm/Machine.cpp
=== modified file 'libcore/asClass.h'
--- a/libcore/asClass.h 2009-05-14 11:23:13 +0000
+++ b/libcore/asClass.h 2009-05-19 15:55:16 +0000
@@ -182,7 +182,11 @@
        asMethod *getConstructor() { return _constructor; }
 
        void setStaticConstructor(asMethod *m) { _staticConstructor = m; }
-       asMethod *getStaticConstructor(){return _staticConstructor;}
+       
+    asMethod* getStaticConstructor() const { 
+        return _staticConstructor;
+    }
+
        void setSuper(asClass *p) { _super = p; }
 
        /// Try to build an asClass object from just a prototype.

=== modified file 'libcore/asMethod.cpp'
--- a/libcore/asMethod.cpp      2009-05-14 11:07:52 +0000
+++ b/libcore/asMethod.cpp      2009-05-19 15:55:16 +0000
@@ -28,9 +28,16 @@
 
 asMethod::asMethod()
     :
+    _methodID(0),
+    _prototype(0),
+    _bodyLength(0),
+    _isNative(false),
        _minArguments(0),
        _maxArguments(0),
-    _body(0)
+    _implementation(0),
+    _flags(0),
+    _body(0),
+    _maxRegisters(0)
 {
 }
 
@@ -54,7 +61,7 @@
 asMethod::setOwner(asClass *pOwner)
 {
        log_debug("asMethod::setOwner");
-       if(!_prototype){
+       if (!_prototype) {
                log_debug("ERROR _prototype is null.");
        }
        log_debug("Prototype text value: %s",_prototype->get_text_value());

=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp    2009-05-18 09:55:06 +0000
+++ b/libcore/vm/Machine.cpp    2009-05-19 15:55:16 +0000
@@ -1265,32 +1265,32 @@
                        }
                }
                // Slot the return.
-//             *mGlobalReturn = as_value();
+        //*mGlobalReturn = as_value();
                // And restore the previous state.
-//             restoreState();
+        //restoreState();
                break;
        }
-/// 0x48 ABC_ACTION_RETURNVALUE
-/// Stack In:
-///  value -- value to be returned
-/// Stack Out:
-///  .
-/// Do: Return value up the callstack.
+    
+    /// 0x48 ABC_ACTION_RETURNVALUE
+    /// Stack In:
+    ///  value -- value to be returned
+    /// Stack Out:
+    ///  .
+    /// Do: Return value up the callstack.
        case SWF::ABC_ACTION_RETURNVALUE:
-       {
                // Slot the return.
                mGlobalReturn = pop_stack();
                // And restore the previous state.
                restoreState();
                return;
-       }
-/// 0x49 ABC_ACTION_CONSTRUCTSUPER
-/// Stream: V32 'arg_count'
-/// Stack In:
-///  argN ... arg1 -- the arg_count arguments
-///  obj -- the object whose super's constructor should be invoked
-/// Stack Out:
-///  .
+    
+    /// 0x49 ABC_ACTION_CONSTRUCTSUPER
+    /// Stream: V32 'arg_count'
+    /// Stack In:
+    ///  argN ... arg1 -- the arg_count arguments
+    ///  obj -- the object whose super's constructor should be invoked
+    /// Stack Out:
+    ///  .
        case SWF::ABC_ACTION_CONSTRUCTSUPER:
        {
                boost::uint32_t argc = mStream->read_V32();
@@ -1444,30 +1444,39 @@
                as_object* new_class = c->getPrototype();
                
                new_class->set_prototype(base_class);
-               //Create the class.
-               as_function* static_constructor = 
c->getStaticConstructor()->getPrototype();
-               as_function* constructor = c->getConstructor()->getPrototype();
-               
new_class->init_member(NSV::PROP_uuCONSTRUCTORuu,as_value(static_constructor),0);
-               
new_class->init_member(NSV::PROP_CONSTRUCTOR,as_value(constructor),0);
+               
+        //Create the class.
+               asMethod* scmethod = c->getStaticConstructor();
+        // What if there isn't one?
+        assert(scmethod);
+        
+        /// This can be null.
+        as_function* static_constructor = scmethod->getPrototype();
+               new_class->init_member(NSV::PROP_uuCONSTRUCTORuu,
+                as_value(static_constructor), 0);
+               
+        as_function* constructor = c->getConstructor()->getPrototype();
+        new_class->init_member(NSV::PROP_CONSTRUCTOR, as_value(constructor), 
0);
                push_stack(as_value(new_class));
 
-               //Call the class's static constructor.
+               // Call the class's static constructor (which may be undefined).
                as_environment env = as_environment(_vm);
-               as_value property = 
new_class->getMember(NSV::PROP_uuCONSTRUCTORuu,0);
-               as_value value = 
call_method(property,env,new_class,get_args(0));
+               as_value property = 
new_class->getMember(NSV::PROP_uuCONSTRUCTORuu, 0);
+               as_value value = call_method(property, env, new_class, 
get_args(0));
 
                break;
        }
-/// 0x59 ABC_ACTION_GETDESCENDANTS
-/// Stream: V32 'name_id'
-/// Stack In:
-///  value -- Whose descendants to get
-///  [ns [n]] -- Namespace stuff
-/// Stack Out:
-///  ?
-/// NB: This op seems to always throw a TypeError in Tamarin, though I
-/// assume that it ought to do something to yield a list of
-/// descendants of a class.
+    
+    /// 0x59 ABC_ACTION_GETDESCENDANTS
+    /// Stream: V32 'name_id'
+    /// Stack In:
+    ///  value -- Whose descendants to get
+    ///  [ns [n]] -- Namespace stuff
+    /// Stack Out:
+    ///  ?
+    /// NB: This op seems to always throw a TypeError in Tamarin, though I
+    /// assume that it ought to do something to yield a list of
+    /// descendants of a class.
        case SWF::ABC_ACTION_GETDESCENDANTS:
        {
                asName a = pool_name(mStream->read_V32(), mPoolObject);
@@ -2088,12 +2097,13 @@
                push_stack(a);
                break;
        }
-/// 0xA1 ABC_ACTION_SUBTRACT
-/// Stack In:
-///  b
-///  a
-/// Stack Out:
-///  a - b (double)
+    
+    /// 0xA1 ABC_ACTION_SUBTRACT
+    /// Stack In:
+    ///  b
+    ///  a
+    /// Stack Out:
+    ///  a - b (double)
        case SWF::ABC_ACTION_SUBTRACT:
        {
                as_value b = pop_stack();


reply via email to

[Prev in Thread] Current Thread [Next in Thread]