[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/parser/movie_def_impl.cp...
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] gnash ChangeLog server/parser/movie_def_impl.cp... |
Date: |
Tue, 03 Jun 2008 18:02:42 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Benjamin Wolsey <bwy> 08/06/03 18:02:42
Modified files:
. : ChangeLog
server/parser : movie_def_impl.cpp movie_def_impl.h
Log message:
* server/movie_def_impl.{h,cpp}: rename confusing typedefs. Add
ostream operator<< for CharacterDictionary, drop dump_chars().
Check return of read, throw parser exception on failure: fixes
a few hangs with -vp for truncated unhandled tags (all my
malformed movies also succeed with -vp now).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6795&r2=1.6796
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.115&r2=1.116
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.h?cvsroot=gnash&r1=1.78&r2=1.79
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6795
retrieving revision 1.6796
diff -u -b -r1.6795 -r1.6796
--- ChangeLog 3 Jun 2008 17:57:44 -0000 1.6795
+++ ChangeLog 3 Jun 2008 18:02:41 -0000 1.6796
@@ -3,6 +3,11 @@
* server/impl.cpp: indentation.
* server/stream.cpp: always check return of read() to avoid reading
past the end of the stream; throw parser exception on failure.
+ * server/movie_def_impl.{h,cpp}: rename confusing typedefs. Add
+ ostream operator<< for CharacterDictionary, drop dump_chars().
+ Check return of read, throw parser exception on failure: fixes
+ a few hangs with -vp for truncated unhandled tags (all my
+ malformed movies also succeed with -vp now).
2008-06-03 Sandro Santilli <address@hidden>
Index: server/parser/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -b -r1.115 -r1.116
--- server/parser/movie_def_impl.cpp 3 Jun 2008 10:41:19 -0000 1.115
+++ server/parser/movie_def_impl.cpp 3 Jun 2008 18:02:42 -0000 1.116
@@ -161,15 +161,21 @@
os << std::endl;
// This decremented until we reach the end of the stream.
- unsigned int toread = in->get_tag_end_position() - in->get_position();
- in->ensureBytes(toread);
+ unsigned int toRead = in->get_tag_end_position() - in->get_position();
+ in->ensureBytes(toRead);
unsigned char buf[rowlength];
- while (toread)
+ while (toRead)
{
// Read in max row length or remainder of stream.
- unsigned int got = in->read(reinterpret_cast<char*>(&buf),
- std::min<unsigned>(toread, rowlength));
+ const unsigned int thisRow = std::min<unsigned int>(toRead, rowlength);
+ const unsigned int got = in->read(reinterpret_cast<char*>(&buf),
thisRow);
+
+ // Check that we read all the bytes we expected.
+ if (got < thisRow)
+ {
+ throw ParserException(_("Unexpected end of stream while reading"));
+ }
// Stream once as hex
os << std::left << std::setw(3 * rowlength) << hexify(buf, got, false);
@@ -177,7 +183,7 @@
// and once as ASCII
os << "| " << hexify(buf, got, true) << std::endl;
- toread -= got;
+ toRead -= got;
}
}
@@ -501,26 +507,29 @@
// CharacterDictionary
//
-void
-CharacterDictionary::dump_chars() const
+std::ostream&
+operator<<(std::ostream& o, const CharacterDictionary& cd)
{
- for ( const_iterator it=begin(), endIt=end();
- it != endIt; ++it )
+
+ for (CharacterDictionary::CharacterConstIterator it = cd.begin(), endIt
= cd.end();
+ it != endIt; it++)
{
- log_debug(_("Character %d @ %p"), it->first,
static_cast<void*>(it->second.get()));
- //character_def* cdef = it->second;
+ o << std::endl
+ << "Character: " << it->first
+ << " at address: " << static_cast<void*>(it->second.get());
}
+
+ return o;
}
boost::intrusive_ptr<character_def>
CharacterDictionary::get_character(int id)
{
- container::iterator it = _map.find(id);
+ CharacterIterator it = _map.find(id);
if ( it == _map.end() )
{
IF_VERBOSE_PARSE(
- log_parse(_("Could not find char %d, dump is:"), id);
- dump_chars();
+ log_parse(_("Could not find char %d, dump is: %s"), id, *this);
);
return boost::intrusive_ptr<character_def>();
}
@@ -532,7 +541,6 @@
{
//log_debug(_("CharacterDictionary: add char %d"), id);
_map[id] = c;
- //dump_chars();
}
// Load next chunk of this sprite frames.
@@ -624,7 +632,7 @@
}
SWF::TagLoadersTable::loader_function lf = NULL;
- //log_parse("tag_type = %d\n", tag_type);
+
if (tag_type == SWF::SHOWFRAME)
{
// show frame tag -- advance to the next frame.
@@ -660,10 +668,9 @@
else
{
// no tag loader for this tag type.
- log_error(_("*** no tag loader for type %d (movie)"),
- tag_type);
+ log_error(_("*** no tag loader for type %d (movie)"), tag_type);
IF_VERBOSE_PARSE(
- std::stringstream ss;
+ std::ostringstream ss;
dumpTagBytes(&str, ss);
log_error("tag dump follows: %s", ss.str());
);
@@ -689,8 +696,7 @@
{
IF_VERBOSE_MALFORMED_SWF(
log_swferror(_("%d control tags are NOT followed by"
- " a SHOWFRAME tag"),
- m_playlist[floaded].size());
+ " a SHOWFRAME tag"), m_playlist[floaded].size());
);
}
Index: server/parser/movie_def_impl.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.h,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -b -r1.78 -r1.79
--- server/parser/movie_def_impl.h 30 May 2008 20:23:51 -0000 1.78
+++ server/parser/movie_def_impl.h 3 Jun 2008 18:02:42 -0000 1.79
@@ -108,11 +108,11 @@
//
/// It contains pairs of 'int' and 'boost::intrusive_ptr<character_def>'
///
- typedef std::map< int, boost::intrusive_ptr<character_def> > container;
+ typedef std::map< int, boost::intrusive_ptr<character_def> >
CharacterContainer;
- typedef container::iterator iterator;
+ typedef CharacterContainer::iterator CharacterIterator;
- typedef container::const_iterator const_iterator;
+ typedef CharacterContainer::const_iterator CharacterConstIterator;
/// Get the Character with the given id
//
@@ -127,25 +127,24 @@
void add_character(int id, boost::intrusive_ptr<character_def> c);
/// Return an iterator to the first dictionary element
- iterator begin() { return _map.begin(); }
+ CharacterIterator begin() { return _map.begin(); }
/// Return a const_iterator to the first dictionary element
- const_iterator begin() const { return _map.begin(); }
+ CharacterConstIterator begin() const { return _map.begin(); }
/// Return an iterator to one-past last dictionary element
- iterator end() { return _map.end(); }
+ CharacterIterator end() { return _map.end(); }
/// Return a const_iterator to one-past last dictionary element
- const_iterator end() const { return _map.end(); }
+ CharacterConstIterator end() const { return _map.end(); }
- /// Dump content of the dictionary (debugging only)
- void dump_chars(void) const;
+ friend std::ostream& operator<<(std::ostream& o, const
CharacterDictionary& cd);
#ifdef GNASH_USE_GC
/// Mark all dictionary items to be reachable (for GC)
void markReachableResources() const
{
- for(const_iterator i=_map.begin(), e=_map.end(); i!=e; ++i)
+ for(CharacterConstIterator i=_map.begin(), e=_map.end(); i!=e;
++i)
{
i->second->setReachable();
}
@@ -154,7 +153,7 @@
private:
- container _map;
+ CharacterContainer _map;
};