gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-


From: Bastiaan Jacques
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_final-2076-ga7ee297
Date: Wed, 28 May 2014 19:00:16 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  a7ee297b3d55b268e6cd4434d93943ad6d1cdde0 (commit)
       via  db5f9de9182c4a384a7a98cc9f08bce49ca9a005 (commit)
       via  953cdc3d19b44eb11ace129f2f8075fc467b5d33 (commit)
      from  36ec3997191eb82135dcd8e5e91bfa0b805e589c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=a7ee297b3d55b268e6cd4434d93943ad6d1cdde0


commit a7ee297b3d55b268e6cd4434d93943ad6d1cdde0
Author: Bastiaan Jacques <address@hidden>
Date:   Wed May 28 20:57:23 2014 +0200

    Mutex-protect _loadingCanceled.
    
    Although changes to _loadingCanceled were recently made atomic, that still
    did not prevent its value changing immediately after it was read by the
    main thread, and immediately before the condition_variable was waited upon.

diff --git a/libcore/parser/SWFMovieDefinition.cpp 
b/libcore/parser/SWFMovieDefinition.cpp
index c0d8976..c827e92 100644
--- a/libcore/parser/SWFMovieDefinition.cpp
+++ b/libcore/parser/SWFMovieDefinition.cpp
@@ -150,6 +150,7 @@ SWFMovieDefinition::SWFMovieDefinition(const RunResources& 
runResources)
 SWFMovieDefinition::~SWFMovieDefinition()
 {
     // Request cancellation of the loading thread
+    std::lock_guard<std::mutex> lock(_loadingCanceledMutex);
     _loadingCanceled = true;
 }
 
@@ -362,11 +363,13 @@ SWFMovieDefinition::ensure_frame_loaded(size_t framenum) 
const
 #ifndef LOAD_MOVIES_IN_A_SEPARATE_THREAD
     return (framenum <= _frames_loaded.load());
 #endif
+    if ( framenum <= _frames_loaded.load() ) {
+        return true;
+    }
 
     _waiting_for_frame = framenum;
 
-    std::mutex m;
-    std::unique_lock<std::mutex> lock(m);
+    std::unique_lock<std::mutex> lock(_loadingCanceledMutex);
 
     // TODO: return false on timeout
 
@@ -454,13 +457,16 @@ SWFMovieDefinition::read_all_swf()
     try {
         while (left) {
 
-            if (_loadingCanceled.load()) {
-                log_debug("Loading thread cancellation requested, "
-                        "returning from read_all_swf");
-                return;
+            {
+                std::lock_guard<std::mutex> lock(_loadingCanceledMutex);
+                if (_loadingCanceled) {
+                    log_debug("Loading thread cancellation requested, "
+                              "returning from read_all_swf");
+                    return;
+                }
             }
             if (!parser.read(std::min<size_t>(left, chunkSize))) break;
-            
+
             left -= parser.bytesRead();
             setBytesLoaded(startPos + parser.bytesRead());
         }
@@ -499,7 +505,10 @@ SWFMovieDefinition::read_all_swf()
         _frames_loaded = m_frame_count;
         // Notify any thread waiting on frame reached condition
     }
-    _loadingCanceled = true;
+    {
+        std::lock_guard<std::mutex> lock(_loadingCanceledMutex);
+        _loadingCanceled = true;
+    }
     _frame_reached_condition.notify_all();
 }
 
diff --git a/libcore/parser/SWFMovieDefinition.h 
b/libcore/parser/SWFMovieDefinition.h
index fc9a3b2..f9aa5a9 100644
--- a/libcore/parser/SWFMovieDefinition.h
+++ b/libcore/parser/SWFMovieDefinition.h
@@ -484,7 +484,8 @@ private:
     }
 
     /// A flag set to true when load cancellation is requested
-    std::atomic<bool> _loadingCanceled;
+    mutable std::mutex _loadingCanceledMutex;
+    bool _loadingCanceled;
 
     /// Movies we import resources from
     std::set< boost::intrusive_ptr<movie_definition> > _importSources;

http://git.savannah.gnu.org/cgit//commit/?id=db5f9de9182c4a384a7a98cc9f08bce49ca9a005


commit db5f9de9182c4a384a7a98cc9f08bce49ca9a005
Author: Bastiaan Jacques <address@hidden>
Date:   Wed May 28 13:07:15 2014 +0200

    Don't write directly into std::string's buffer.

diff --git a/plugin/npapi/pluginScriptObject.cpp 
b/plugin/npapi/pluginScriptObject.cpp
index e40665b..3b599c8 100644
--- a/plugin/npapi/pluginScriptObject.cpp
+++ b/plugin/npapi/pluginScriptObject.cpp
@@ -725,19 +725,14 @@ GnashPluginScriptObject::readPlayer(int fd)
         return empty;
     }
 
-    std::string buf(bytes, '\0');
+    char buf[bytes];
 
-    // FIXME: writing into string data buffers is an undefined operation.
-    int ret = ::read(fd, &buf[0], bytes);
-    if (ret <= 0) {
+    int ret = ::read(fd, buf, bytes);
+    if (ret <= 0 || ret > bytes) {
         return empty;
     }
 
-    if (ret < bytes) {
-        buf.resize(ret);
-    }
-
-    return buf;
+    return std::string(buf, ret);
 }
 
 

http://git.savannah.gnu.org/cgit//commit/?id=953cdc3d19b44eb11ace129f2f8075fc467b5d33


commit 953cdc3d19b44eb11ace129f2f8075fc467b5d33
Author: Bastiaan Jacques <address@hidden>
Date:   Wed May 28 00:47:27 2014 +0200

    Avoid undefined behaviour.

diff --git a/libcore/vm/ASHandlers.cpp b/libcore/vm/ASHandlers.cpp
index 0018fb8..3fe5bac 100644
--- a/libcore/vm/ASHandlers.cpp
+++ b/libcore/vm/ASHandlers.cpp
@@ -3012,7 +3012,7 @@ ActionShiftLeft(ActionExec& thread)
     std::uint32_t amount = saneShiftParam(toInt(env.top(0), getVM(env)));
     std::int32_t value = toInt(env.top(1), getVM(env));
 
-    value = value << amount;
+    value = static_cast<std::uint32_t>(value) << amount;
 
     env.top(1) = value;
     env.drop(1);

-----------------------------------------------------------------------

Summary of changes:
 libcore/parser/SWFMovieDefinition.cpp |   25 +++++++++++++++++--------
 libcore/parser/SWFMovieDefinition.h   |    3 ++-
 libcore/vm/ASHandlers.cpp             |    2 +-
 plugin/npapi/pluginScriptObject.cpp   |   13 ++++---------
 4 files changed, 24 insertions(+), 19 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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