[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/button_character_instanc...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/button_character_instanc... |
Date: |
Thu, 13 Dec 2007 23:01:16 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/12/13 23:01:16
Modified files:
. : ChangeLog
server : button_character_instance.cpp
server/parser : button_character_def.cpp button_character_def.h
Log message:
Fix button action buffers leak
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5167&r2=1.5168
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.68&r2=1.69
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/button_character_def.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/button_character_def.h?cvsroot=gnash&r1=1.22&r2=1.23
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5167
retrieving revision 1.5168
diff -u -b -r1.5167 -r1.5168
--- ChangeLog 13 Dec 2007 21:33:40 -0000 1.5167
+++ ChangeLog 13 Dec 2007 23:01:15 -0000 1.5168
@@ -1,5 +1,12 @@
2007-12-13 Sandro Santilli <address@hidden>
+ * server/parser/button_character_def.{cpp,h}: don't leak
+ button action buffers.
+ * server/button_character_instance.cpp: update access to
+ button actions (needs more isolation work).
+
+2007-12-13 Sandro Santilli <address@hidden>
+
* server/Property.h: always initialize mOrderId, which is used
as the key for secondary multi_index in PropertyList.
Seems to fix the infamous conditional jumps based on uninitialized
Index: server/button_character_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -b -r1.68 -r1.69
--- server/button_character_instance.cpp 12 Dec 2007 06:16:31 -0000
1.68
+++ server/button_character_instance.cpp 13 Dec 2007 23:01:15 -0000
1.69
@@ -264,9 +264,11 @@
attachButtonInterface(*this);
// check up presence Key events
+ // TODO: use a service of button_character_def, not this hard-coded
thing here
for (size_t i = 0, e = m_def->m_button_actions.size(); i < e; ++i)
{
- if (m_def->m_button_actions[i].m_conditions & 0xFE00) //
check up on CondKeyPress: UB[7]
+ // TODO: use labels, not magic numbers here !!
+ if (m_def->m_button_actions[i]->m_conditions & 0xFE00) //
check up on CondKeyPress: UB[7]
{
_vm.getRoot().add_key_listener(this);
break;
@@ -335,17 +337,14 @@
// TODO: should we execute immediately instead ?
for (size_t i = 0, ie=m_def->m_button_actions.size(); i<ie; ++i)
{
- button_action& ba = m_def->m_button_actions[i];
+ button_action& ba = *(m_def->m_button_actions[i]);
int keycode = (ba.m_conditions & 0xFE00) >> 9;
event_id key_event(event_id::KEY_PRESS, (key::code) keycode);
if (key_event == id)
{
// Matching action.
- for (size_t j=0, je=ba.m_actions.size(); j<je; ++j)
- {
-
VM::get().getRoot().pushAction(*(ba.m_actions[j]),
boost::intrusive_ptr<character>(this));
- }
+ VM::get().getRoot().pushAction(ba.m_actions,
boost::intrusive_ptr<character>(this));
called = true;
}
}
@@ -580,21 +579,18 @@
for (size_t i = 0; i < m_def->m_button_actions.size(); i++)
{
- if (m_def->m_button_actions[i].m_conditions & c)
+ button_action& ba = *(m_def->m_button_actions[i]);
+
+ if (ba.m_conditions & c)
{
// Matching action.
- for (size_t j = 0; j <
m_def->m_button_actions[i].m_actions.size(); j++)
- {
- action_buffer* ab =
m_def->m_button_actions[i].m_actions[j];
- assert(ab);
+ action_buffer& ab = ba.m_actions;
IF_VERBOSE_ACTION(
log_action(_("Executing actions for "
"button condition %d"), c);
);
- ActionExec exec(*ab, get_environment());
+ ActionExec exec(ab, get_environment());
exec();
-
- }
}
}
Index: server/parser/button_character_def.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/button_character_def.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/parser/button_character_def.cpp 13 Dec 2007 10:58:10 -0000
1.22
+++ server/parser/button_character_def.cpp 13 Dec 2007 23:01:15 -0000
1.23
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: button_character_def.cpp,v 1.22 2007/12/13 10:58:10 strk Exp $ */
+/* $Id: button_character_def.cpp,v 1.23 2007/12/13 23:01:15 strk Exp $ */
// Based on the public domain work of Thatcher Ulrich <address@hidden> 2003
@@ -36,27 +36,7 @@
//
-button_action::~button_action()
-{
- for (ActionList::iterator i=m_actions.begin(), e=m_actions.end();
- i != e; ++i)
- {
- // We can NOT delete action_buffers here becase they
- // may contain the action currently being executed and
- // triggering the deletion.
- // I'm not really sure about whether this is the problem,
- // anyway clip_as_button2.swf fails on segfault when clicking
- // the upper-right button if we delete here.
- //
- // TODO: properly implement management of these resources
- // which are otherwise just leaking..
- //
- //delete (*i);
- }
- m_actions.clear(); // this is useless, will be done automatically
-}
-
-void button_action::read(stream* in, int tag_type, unsigned long endPos)
+button_action::button_action(stream& in, int tag_type, unsigned long endPos)
{
// Read condition flags.
if (tag_type == SWF::DEFINEBUTTON) // 7
@@ -67,14 +47,14 @@
{
assert(tag_type == SWF::DEFINEBUTTON2); // 34
- if ( in->get_position()+2 > endPos )
+ if ( in.get_position()+2 > endPos )
{
IF_VERBOSE_MALFORMED_SWF(
log_swferror(_("Premature end of button action input:
can't read conditions"));
);
return;
}
- m_conditions = in->read_u16();
+ m_conditions = in.read_u16();
}
IF_VERBOSE_PARSE (
@@ -82,9 +62,7 @@
);
// Read actions.
- action_buffer* a = new action_buffer;
- a->read(*in, endPos);
- m_actions.push_back(a);
+ m_actions.read(in, endPos);
}
//
@@ -189,7 +167,12 @@
button_character_definition::~button_character_definition()
{
- delete m_sound;
+ for (ButtonActVect::iterator i=m_button_actions.begin(),
+ ie=m_button_actions.end();
+ i != ie; ++i )
+ {
+ delete *i;
+ }
}
@@ -272,10 +255,7 @@
}
// Read actions.
- button_action actions;
- // TODO: pass valid end position to button_action parser
- actions.read(in, SWF::DEFINEBUTTON, endTagPos);
- m_button_actions.push_back(actions);
+ m_button_actions.push_back(new button_action(*in, SWF::DEFINEBUTTON,
endTagPos));
// detect min/max layer number
m_min_layer=0;
@@ -347,8 +327,7 @@
unsigned long endActionPos = next_action_offset ?
next_action_pos : tagEndPosition;
- m_button_actions.resize(m_button_actions.size() + 1);
- m_button_actions.back().read(in, SWF::DEFINEBUTTON2,
endActionPos);
+ m_button_actions.push_back(new button_action(*in,
SWF::DEFINEBUTTON2, endActionPos));
if (next_action_offset == 0 )
{
@@ -396,7 +375,7 @@
return;
}
- m_sound = new button_sound_def();
+ m_sound.reset( new button_sound_def() );
IF_VERBOSE_PARSE(
log_parse(_("button sound options: "));
Index: server/parser/button_character_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/button_character_def.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/parser/button_character_def.h 13 Dec 2007 10:58:10 -0000
1.22
+++ server/parser/button_character_def.h 13 Dec 2007 23:01:15 -0000
1.23
@@ -15,6 +15,9 @@
#include "rect.h" // for get_bound
#include "matrix.h" // for composition
#include "cxform.h" // for composition
+#include "action_buffer.h" // for composition of button_action
+
+#include <boost/scoped_ptr.hpp>
#ifndef UNUSED
#define UNUSED(x) ((x) = (x))
@@ -23,7 +26,6 @@
// Forward declarations
namespace gnash {
class sprite_instance;
- class action_buffer;
}
namespace gnash {
@@ -39,7 +41,10 @@
bool m_over;
bool m_up;
int m_character_id;
+
+ // Who owns this ?
character_def* m_character_def;
+
int m_button_layer;
matrix m_button_matrix;
cxform m_button_cxform;
@@ -99,17 +104,14 @@
};
int m_conditions;
- typedef std::vector<action_buffer*> ActionList;
-
// TODO: define ownership of list elements !!
- ActionList m_actions;
-
- ~button_action();
+ action_buffer m_actions;
/// @param endPos
/// One past last valid-to-read byte position
///
- void read(stream* in, int tag_type, unsigned long endPos);
+ button_action(stream& in, int tag_type, unsigned long endPos);
+
};
@@ -190,11 +192,10 @@
typedef std::vector<button_record> ButtonRecVect;
ButtonRecVect m_button_records;
- typedef std::vector<button_action> ButtonActVect;
+ typedef std::vector<button_action*> ButtonActVect;
ButtonActVect m_button_actions;
- // TODO: define ownership of this sound !
- button_sound_def* m_sound;
+ boost::scoped_ptr<button_sound_def> m_sound;
button_character_definition();
virtual ~button_character_definition();
@@ -248,6 +249,7 @@
{
i->markReachableResources();
}
+
if ( m_sound ) m_sound->markReachableResources();
}
#endif // GNASH_USE_GC