[mathicgb] 59/393: Fixed overflow issue that would only happen on 64 bit compiles with hash tables or geobuckets larger than 2^31. After this change, all remaining issues found by the static analysis of Visual Studio 2012 Professional are false positives.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:58:32 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.
commit 5a1c8e41aa7de09e8e194995c6e90fc311875b11
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Fri Oct 12 18:39:11 2012 +0200
Fixed overflow issue that would only happen on 64 bit compiles with hash tables or geobuckets larger than 2^31. After this change, all remaining issues found by the static analysis of Visual Studio 2012 Professional are false positives.
---
src/mathicgb/ChainedHashTable.hpp | 2 +-
src/mathicgb/PolyGeoBucket.cpp | 6 +++++-
src/mathicgb/PolyHashTable.cpp | 4 ++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/mathicgb/ChainedHashTable.hpp b/src/mathicgb/ChainedHashTable.hpp
index 7e87c15..f6e3cef 100644
--- a/src/mathicgb/ChainedHashTable.hpp
+++ b/src/mathicgb/ChainedHashTable.hpp
@@ -98,7 +98,7 @@ private:
template <typename HashControl>
ChainedHashTable<HashControl>::ChainedHashTable(HashControl M, int nbits)
: M_(M),
- table_size_(1 << nbits)
+ table_size_(static_cast<size_t>(1) << nbits)
{
hashtable_.resize(table_size_);
diff --git a/src/mathicgb/PolyGeoBucket.cpp b/src/mathicgb/PolyGeoBucket.cpp
index a6cf60a..6538c13 100755
--- a/src/mathicgb/PolyGeoBucket.cpp
+++ b/src/mathicgb/PolyGeoBucket.cpp
@@ -2,6 +2,7 @@
#include "stdinc.h"
#include "PolyGeoBucket.hpp"
+#include <mathic.h>
const size_t heap_size[GEOHEAP_SIZE] = {4, 16, 64, 256, 1024, 4096,
16384, 65536, 262144, 1048576, 4194304,
@@ -101,8 +102,11 @@ void PolyGeoBucket::insert(heap_record &a)
len = heap[i].last - heap[i].first;
}
}
- if (i > top_of_heap)
+ if (i > top_of_heap) {
top_of_heap = i;
+ if (i >= GEOHEAP_SIZE)
+ mic::reportInternalError("Too many levels in PolyGeoBucket.");
+ }
stats_n_inserts++;
update_size_stats();
diff --git a/src/mathicgb/PolyHashTable.cpp b/src/mathicgb/PolyHashTable.cpp
index 71a79c8..49c5b6c 100755
--- a/src/mathicgb/PolyHashTable.cpp
+++ b/src/mathicgb/PolyHashTable.cpp
@@ -12,8 +12,8 @@ const bool AlwaysInsertAtEnd = true;
PolyHashTable::PolyHashTable(const PolyRing *R, int nbits)
: mRing(*R),
- mHashMask((1 << nbits)-1),
- mTableSize(1 << nbits),
+ mHashMask((static_cast<size_t>(1) << nbits)-1),
+ mTableSize(static_cast<size_t>(1) << nbits),
mLogTableSize(nbits),
mNodeCount(0),
mBinCount(0),
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git
More information about the debian-science-commits
mailing list