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-1995-g2824ebb
Date: Sun, 18 May 2014 17:03:44 +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  2824ebbcca627bca43e642622d9bc1b5b7f69162 (commit)
      from  add735e872cf04379d067110ef04804ae4f058e8 (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=2824ebbcca627bca43e642622d9bc1b5b7f69162


commit 2824ebbcca627bca43e642622d9bc1b5b7f69162
Author: Bastiaan Jacques <address@hidden>
Date:   Sun May 18 19:01:26 2014 +0200

    Savannah #42385: fix signed integer overflow by using larger datatypes.

diff --git a/libbase/Range2d.h b/libbase/Range2d.h
index 439004a..a349096 100644
--- a/libbase/Range2d.h
+++ b/libbase/Range2d.h
@@ -28,6 +28,7 @@
 #include <algorithm>
 #include <cassert> // for inlines
 #include <cmath> // for floor / ceil
+#include <boost/cstdint.hpp>
 
 namespace gnash {
 
@@ -51,6 +52,13 @@ enum RangeKind {
        worldRange
 };
 
+namespace detail {
+    template <typename U> struct Promote { typedef U type; };
+    template <> struct Promote<float> { typedef double type; };
+    template <> struct Promote<int> { typedef boost::int64_t type; };
+    template <> struct Promote<unsigned int> { typedef boost::uint64_t type; };
+}
+
 /// 2d Range template class
 //
 /// The class stores 4 values of the type specified
@@ -627,16 +635,19 @@ public:
                assert ( isFinite() );
                return _ymax;
        }
-       
-       /// Get area (width*height)
-    ///  
-       T getArea() const {
-        assert ( !isWorld() );
-        if ( isNull() ) return 0;
-        return (_xmax - _xmin) * (_ymax - _ymin);
-        // this implementation is for float types, see specialization below
-        // for ints... 
-    } 
+
+
+        /// Get area (width*height)
+        //
+        typename detail::Promote<T>::type
+        getArea() const {
+            assert ( !isWorld() );
+            if ( isNull() ) return 0;
+            return static_cast<typename detail::Promote<T>::type>(_xmax - 
_xmin)
+                   * (_ymax - _ymin);
+            // this implementation is for float types, see specialization below
+            // for ints...
+        }
 
        /// Expand this range to include the given Range2d
        //
@@ -823,23 +834,27 @@ Range2d<unsigned int>::roundMax(float max) const
 //
 /// Add one.
 ///
-template<> inline int
+template<> inline
+detail::Promote<int>::type
 Range2d<int>::getArea() const
 {
     assert ( !isWorld() );
     if ( isNull() ) return 0;
-    return (_xmax - _xmin + 1) * (_ymax - _ymin + 1);
+    return static_cast<detail::Promote<int>::type>(_xmax - _xmin + 1) *
+               (_ymax - _ymin + 1);
 }
 
 /// Specialization of area value for unsigned int type.
 //
 /// Add one.
 ///
-template<> inline unsigned int
+template<> inline
+detail::Promote<unsigned int>::type
 Range2d<unsigned int>::getArea() const
 {
     assert ( isFinite() );
-    return (_xmax - _xmin + 1) * (_ymax - _ymin + 1);
+    return static_cast<detail::Promote<unsigned int>::type>(_xmax - _xmin + 1) 
*
+              (_ymax - _ymin + 1);
 }
 
 

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

Summary of changes:
 libbase/Range2d.h |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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