From fa8ff6d5b6c95c765e306cf563c5c33d9b85bb82 Mon Sep 17 00:00:00 2001 From: Tiago Gomes Date: Mon, 30 Apr 2012 12:48:30 +0100 Subject: [PATCH] abort if the factor will become to bigger --- packages/CLPBN/clpbn/bp/Factor.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/CLPBN/clpbn/bp/Factor.h b/packages/CLPBN/clpbn/bp/Factor.h index e38650c3a..e85a6e6b3 100644 --- a/packages/CLPBN/clpbn/bp/Factor.h +++ b/packages/CLPBN/clpbn/bp/Factor.h @@ -90,6 +90,13 @@ class TFactor for (unsigned i = 0; i < g_args.size(); i++) { int idx = indexOf (g_args[i]); if (idx == -1) { + Params::size_type newSize = params_.size() * g_ranges[i]; + if (newSize > Util::maxUnsigned()) { + // factor will become to bigger, is not worth to continue + cerr << "error: an overflow occurred when performing expansion" ; + cerr << endl; + abort(); + } insertArgument (g_args[i], g_ranges[i]); gvarpos.push_back (args_.size() - 1); } else {