[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/swf/ASHandlers.cpp
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/swf/ASHandlers.cpp |
Date: |
Wed, 04 Oct 2006 15:21:21 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/10/04 15:21:21
Modified files:
. : ChangeLog
server/swf : ASHandlers.cpp
Log message:
* server/swf/ASHandlers.cpp: cleanly handle recursion (with
loops check) in enumerate actions.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1032&r2=1.1033
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/ASHandlers.cpp?cvsroot=gnash&r1=1.72&r2=1.73
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1032
retrieving revision 1.1033
diff -u -b -r1.1032 -r1.1033
--- ChangeLog 4 Oct 2006 15:04:00 -0000 1.1032
+++ ChangeLog 4 Oct 2006 15:21:21 -0000 1.1033
@@ -1,5 +1,7 @@
2006-10-04 Sandro Santilli <address@hidden>
+ * server/swf/ASHandlers.cpp: cleanly handle recursion (with
+ loops check) in enumerate actions.
* server/asobj/Global.cpp (as_global_object_ctor): fix
copy constructor of the Object class.
* testsuite/actionscript.all/Object.as: added copy-reference
Index: server/swf/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/ASHandlers.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- server/swf/ASHandlers.cpp 3 Oct 2006 16:11:54 -0000 1.72
+++ server/swf/ASHandlers.cpp 4 Oct 2006 15:21:21 -0000 1.73
@@ -34,7 +34,7 @@
// forward this exception.
//
-/* $Id: ASHandlers.cpp,v 1.72 2006/10/03 16:11:54 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.73 2006/10/04 15:21:21 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -59,6 +59,7 @@
#include <string>
#include <map>
+#include <set>
#include <vector>
using namespace std;
@@ -2201,18 +2202,21 @@
dbglogfile << __PRETTY_FUNCTION__ << ": unimplemented!" << endl;
}
-// Push a each object's member value on the stack
-// This is an utility function for use by ActionEnumerate
-// and ActionEnum2. The caller is expected to have
-// already set the top-of-stack to the NULL value (as an optimization)
+/// Recursive enumerator. Will keep track of visited object
+/// to avoid loops in prototype chain.
+/// NOTE: the MM player just chokes in this case.
+/// TODO: avoid recursion and use a visited stack
static void
-enumerateObject(as_environment& env, const as_object& obj)
+enumerateObjectRecursive(as_environment& env, const as_object& obj,
+ std::set<const as_object*>& visited)
{
-
- assert( env.top(0).get_type() == as_value::NULLTYPE );
+ if ( ! visited.insert(&obj).second )
+ {
+ log_warning("prototype loop during Enumeration");
+ return;
+ }
typedef stringi_hash<as_member>::const_iterator members_iterator;
-
for ( members_iterator
it=obj.m_members.begin(), itEnd=obj.m_members.end();
it!=itEnd;
@@ -2233,34 +2237,26 @@
}
}
- // Enumerate __proto__ ?? are we sure this is required ?
- // Should we recurse then ?
-
const as_object *prototype = obj.m_prototype;
-
- if (prototype == NULL) return; // no proto, no enums
-
- const as_object& proto = *prototype; // just type less ;)
- for ( members_iterator
- it=proto.m_members.begin(), itEnd=proto.m_members.end();
- it!=itEnd;
- ++it )
+ if ( prototype )
{
- const as_member member = it->second;
+ enumerateObjectRecursive(env, *prototype, visited);
+ }
- if (! member.get_member_flags().get_dont_enum())
- {
- // shouldn't this be a tu_string instead ?
- // we need to support UTF8 too I guess
- const char* val = it->first.c_str();
+}
- env.push(as_value(val));
- IF_VERBOSE_ACTION (
- log_action("---enumerate - push: %s", val);
- );
- }
+// Push a each object's member value on the stack
+// This is an utility function for use by ActionEnumerate
+// and ActionEnum2. The caller is expected to have
+// already set the top-of-stack to the NULL value (as an optimization)
+static void
+enumerateObject(as_environment& env, const as_object& obj)
+{
+
+ assert( env.top(0).get_type() == as_value::NULLTYPE );
+ std::set<const as_object*> visited;
- };
+ enumerateObjectRecursive(env, obj, visited);
}
- [Gnash-commit] gnash ChangeLog server/swf/ASHandlers.cpp,
Sandro Santilli <=