From 778df1879a0f38e4a8684e14e325f0a805ee8dcf Mon Sep 17 00:00:00 2001 From: "Wu, Ke" Date: Wed, 8 Oct 2014 07:32:42 -0400 Subject: Fix an out-of-bound access bug in maxent --- utils/maxent.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/maxent.cpp b/utils/maxent.cpp index 8d00ac1d..9115f6f2 100644 --- a/utils/maxent.cpp +++ b/utils/maxent.cpp @@ -98,7 +98,7 @@ int ME_Model::conditional_probability(const Sample& s, std::vector& membp) const { // int num_classes = membp.size(); double sum = 0; - int max_label = -1; + int max_label = 0; // double maxp = 0; vector powv(_num_classes, 0.0); @@ -134,7 +134,6 @@ int ME_Model::conditional_probability(const Sample& s, membp[label] /= sum; if (membp[label] > membp[max_label]) max_label = label; } - assert(max_label >= 0); return max_label; } -- cgit v1.2.3