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-1673-g75671d1
Date: Wed, 17 Jul 2013 22:24:27 +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  75671d174cc31134e001b879f73aeae4a6d89dc6 (commit)
      from  32107faeb82191284d6e5de16705777faa93bdde (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=75671d174cc31134e001b879f73aeae4a6d89dc6


commit 75671d174cc31134e001b879f73aeae4a6d89dc6
Author: Bastiaan Jacques <address@hidden>
Date:   Thu Jul 18 00:19:42 2013 +0200

    Sanitize the right bitshift operands in addition to the left shift operands.
    
    This should make the result of AS right shifts with funny right operands
    on ARM the same as on x86*.

diff --git a/libcore/vm/ASHandlers.cpp b/libcore/vm/ASHandlers.cpp
index 92f9cd9..05121d1 100644
--- a/libcore/vm/ASHandlers.cpp
+++ b/libcore/vm/ASHandlers.cpp
@@ -2994,17 +2994,22 @@ ActionBitwiseXor(ActionExec& thread)
     env.drop(1);
 }
 
+inline boost::uint32_t
+saneShiftParam(boost::int32_t value)
+{
+    // NOTE: ISO-IEC 14882:2003 5.8.1: "The behavior is undefined if the right
+    // operand is negative, or greater than or equal to the length in bits of
+    // the promoted left operand."
+    boost::uint32_t rv = value;
+    return rv % 32;
+}
+
 void
 ActionShiftLeft(ActionExec& thread)
 {
     as_environment& env = thread.env;
 
-    /// A left shift of more than or equal to the size in
-    /// bits of the left operand, or a negative shift, results
-    /// in undefined behaviour in C++.
-    boost::int32_t amount = toInt(env.top(0), getVM(env)) % 32;
-    if (amount < 0) amount += 32;
-    
+    boost::uint32_t amount = saneShiftParam(toInt(env.top(0), getVM(env)));
     boost::int32_t value = toInt(env.top(1), getVM(env));
 
     value = value << amount;
@@ -3018,8 +3023,7 @@ ActionShiftRight(ActionExec& thread)
 {
     as_environment& env = thread.env;
 
-    // This is UB.
-    boost::uint32_t amount = toInt(env.top(0), getVM(env));
+    boost::uint32_t amount = saneShiftParam(toInt(env.top(0), getVM(env)));
     boost::int32_t value = toInt(env.top(1), getVM(env));
 
     value = value >> amount;
@@ -3033,11 +3037,10 @@ ActionShiftRight2(ActionExec& thread)
 {
     as_environment& env = thread.env;
 
-    // This is UB
-    boost::uint32_t amount = toInt(env.top(0), getVM(env)); 
+    boost::uint32_t amount = saneShiftParam(toInt(env.top(0), getVM(env))); 
     boost::int32_t value = toInt(env.top(1), getVM(env));
 
-    value = boost::uint32_t(value) >> amount;
+    value = static_cast<boost::uint32_t>(value) >> amount;
 
     env.top(1) = value;
     env.drop(1);

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

Summary of changes:
 libcore/vm/ASHandlers.cpp |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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