gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r9567: Fix for a segfault in sound_h


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r9567: Fix for a segfault in sound_handler_sdl.cpp.
Date: Thu, 07 Aug 2008 16:42:06 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9567
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2008-08-07 16:42:06 +0200
message:
  Fix for a segfault in sound_handler_sdl.cpp.
  
  Drop some unused functions.
modified:
  gui/gui.cpp
  libcore/impl.cpp
  libcore/impl.h
  libmedia/ffmpeg/sound_handler_sdl.cpp
    ------------------------------------------------------------
    revno: 9565.1.4
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2008-08-07 15:21:24 +0200
    message:
      Drop unused statics in impl.cpp. Drop unused or unnecessary global
      methods in impl.h, including get_current_root().
      
      Replace get_current_root() use in gui.cpp (disabled step back/forward 
methods)
      with VM::get().getRoot();
    modified:
      gui/gui.cpp
      libcore/impl.cpp
      libcore/impl.h
    ------------------------------------------------------------
    revno: 9565.1.5
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2008-08-07 16:39:40 +0200
    message:
      Don't dereference sound data that has already been deleted either in
      delete_all_sounds or stop_all_sounds. Fixes a segfault on exit in
      SWF8/game_start_ch2.swf.
    modified:
      libmedia/ffmpeg/sound_handler_sdl.cpp
=== modified file 'gui/gui.cpp'
--- a/gui/gui.cpp       2008-08-04 07:57:53 +0000
+++ b/gui/gui.cpp       2008-08-07 13:21:24 +0000
@@ -437,29 +437,29 @@
 void
 Gui::menu_step_forward()
 {
-       movie_root* m = get_current_root();
-       m->goto_frame(m->get_current_frame()+1);
+       movie_root& m = VM::get().getRoot();
+       m.goto_frame(m.get_current_frame()+1);
 }
 
 void
 Gui::menu_step_backward()
 {
-       movie_root* m = get_current_root();
-       m->goto_frame(m->get_current_frame()-1);
+       movie_root& m = VM::get().getRoot();
+       m.goto_frame(m.get_current_frame()-1);
 }
 
 void
 Gui::menu_jump_forward()
 {
-       movie_root* m = get_current_root();
-       m->goto_frame(m->get_current_frame()+10);
+       movie_root& m = VM::get().getRoot();
+       m.goto_frame(m.get_current_frame()+10);
 }
 
 void
 Gui::menu_jump_backward()
 {
-       movie_root* m = get_current_root();
-       m->goto_frame(m->get_current_frame()-10);
+       movie_root& m = VM::get().getRoot();
+       m.goto_frame(m.get_current_frame()-10);
 }
 
 void

=== modified file 'libcore/impl.cpp'
--- a/libcore/impl.cpp  2008-08-06 16:29:15 +0000
+++ b/libcore/impl.cpp  2008-08-07 13:21:24 +0000
@@ -200,8 +200,8 @@
     register_tag_loader(SWF::PLACEFUNCTION, fixme_loader); // 54 
     register_tag_loader(SWF::GENTAGOBJECT, fixme_loader); // 55 
 
-    register_tag_loader(SWF::EXPORTASSETS,  export_loader); // 56
-    register_tag_loader(SWF::IMPORTASSETS,  import_loader); // 57
+    register_tag_loader(SWF::EXPORTASSETS, export_loader); // 56
+    register_tag_loader(SWF::IMPORTASSETS, import_loader); // 57
 
     //  We're not an authoring tool so we don't care.
     // (might be nice to dump the password instead..)
@@ -509,8 +509,6 @@
 //
 
 
-//static stringi_hash< boost::intrusive_ptr<movie_definition> > 
s_movie_library;
-
 /// Library of SWF movies indexed by URL strings
 //
 /// Elements are actually SWFMovieDefinition, the ones
@@ -581,9 +579,10 @@
   {
   
     if (_limit)
+    {
       limit_size(_limit-1);
-    else
-      return;  // zero limit, library is a no-op
+    }
+    else return;  // zero limit, library is a no-op
   
     item temp;
     
@@ -628,41 +627,18 @@
 };
 
 static MovieLibrary s_movie_library;
-
-typedef std::map< movie_definition*, boost::intrusive_ptr<sprite_instance> > 
library_container_t;
-static library_container_t  s_movie_library_inst;
 static std::vector<sprite_instance*> s_extern_sprites;
 
-static std::string s_workdir;
-
 void save_extern_movie(sprite_instance* m)
 {
     s_extern_sprites.push_back(m);
 }
 
-movie_root*
-get_current_root()
-{
-  return &(VM::get().getRoot());
-}
-
-const char* get_workdir()
-{
-    return s_workdir.c_str();
-}
-
-void set_workdir(const char* dir)
-{
-    assert(dir != NULL);
-    s_workdir = dir;
-}
-
 static void clear_library()
     // Drop all library references to movie_definitions, so they
     // can be cleaned up.
 {
     s_movie_library.clear();
-    s_movie_library_inst.clear();
 }
 
 // Try to load a movie from the given url, if we haven't

=== modified file 'libcore/impl.h'
--- a/libcore/impl.h    2008-06-09 09:18:18 +0000
+++ b/libcore/impl.h    2008-08-07 13:21:24 +0000
@@ -25,64 +25,13 @@
 #include "smart_ptr.h"
 #include "swf/TagLoadersTable.h"
 
-#include <cassert>
-
 namespace gnash {
 
 // Forward declarations
-//class action_buffer;
-class bitmap_character_def;
-class bitmap_info;
-class character;
-class character_def;
-class font;
-class movie_root;
 class sprite_instance;
 
 DSOEXPORT void save_extern_movie(sprite_instance* m);
 
-
-// for extern movies
-
-DSOEXPORT movie_root* get_current_root();
-DSOEXPORT const char* get_workdir();
-DSOEXPORT void set_workdir(const char* dir);
-
-#if 0
-// Information about how to display a character.
-class display_info
-{
-public:
-    movie*     m_parent;
-    int        m_depth;
-    cxform     m_color_transform;
-    matrix     m_matrix;
-    float      m_ratio;
-    boost::uint16_t    m_clip_depth;
-
-    display_info()
-       :
-       m_parent(NULL),
-       m_depth(0),
-       m_ratio(0.0f),
-       m_clip_depth(0)
-       {
-       }
-
-    void       concatenate(const display_info& di)
-       // Concatenate the transforms from di into our
-       // transforms.
-       {
-           m_depth = di.m_depth;
-           m_color_transform.concatenate(di.m_color_transform);
-           m_matrix.concatenate(di.m_matrix);
-           m_ratio = di.m_ratio;
-           m_clip_depth = di.m_clip_depth;
-       }
-};
-#endif
-
-
 //
 // Loader callbacks.
 //
@@ -92,8 +41,8 @@
 // to call this in order to handle special tag types.
 
 /// Register a tag loader for the given tag
-void   register_tag_loader(SWF::tag_type t,
-               SWF::TagLoadersTable::loader_function lf);
+void register_tag_loader(SWF::tag_type t,
+        SWF::TagLoadersTable::loader_function lf);
        
 }      // end namespace gnash
 

=== modified file 'libmedia/ffmpeg/sound_handler_sdl.cpp'
--- a/libmedia/ffmpeg/sound_handler_sdl.cpp     2008-07-19 11:13:08 +0000
+++ b/libmedia/ffmpeg/sound_handler_sdl.cpp     2008-08-07 14:39:40 +0000
@@ -135,9 +135,12 @@
 
        boost::mutex::scoped_lock lock(_mutex);
 
-       for (size_t i=0, e=m_sound_data.size(); i < e; ++i)
+       for (Sounds::iterator i = m_sound_data.begin(),
+                             e = m_sound_data.end(); i != e; ++i)
        {
-               sound_data* sounddata = m_sound_data[i];
+               sound_data* sounddata = *i;
+        // The sound may have been deleted already.
+        if (!sounddata) continue;
 
                size_t nActiveSounds = sounddata->m_active_sounds.size();
                soundsPlaying -= nActiveSounds;
@@ -381,6 +384,8 @@
 {
        boost::mutex::scoped_lock lock(_mutex);
 
+    log_debug ("deleting sound :%d", sound_handle);
+
        if (sound_handle >= 0 && static_cast<unsigned int>(sound_handle) < 
m_sound_data.size())
        {
                delete m_sound_data[sound_handle];
@@ -396,9 +401,13 @@
 {
        boost::mutex::scoped_lock lock(_mutex);
 
-       for (Sounds::iterator i=m_sound_data.begin(), e=m_sound_data.end(); 
i!=e; ++i)
+       for (Sounds::iterator i = m_sound_data.begin(),
+                             e = m_sound_data.end(); i != e; ++i)
        {
                sound_data* sounddata = *i;
+
+        // The sound may have been deleted already.            
+               if (!sounddata) continue;
                size_t nActiveSounds = sounddata->m_active_sounds.size();
 
                soundsPlaying -= nActiveSounds;


reply via email to

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