[mlpack] 23/40: Check number of columns.

Barak A. Pearlmutter barak+git at pearlmutter.net
Mon Feb 15 19:34:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch master
in repository mlpack.

commit f4888d95467a5595ac83f53e08d4c7a352f55027
Author: Ryan Curtin <ryan at ratml.org>
Date:   Fri Jan 29 09:55:38 2016 -0800

    Check number of columns.
---
 src/mlpack/core/data/load_arff_impl.hpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/mlpack/core/data/load_arff_impl.hpp b/src/mlpack/core/data/load_arff_impl.hpp
index daee955..88e4282 100644
--- a/src/mlpack/core/data/load_arff_impl.hpp
+++ b/src/mlpack/core/data/load_arff_impl.hpp
@@ -168,6 +168,14 @@ void LoadARFF(const std::string& filename,
     std::stringstream token;
     for (Tokenizer::iterator it = tok.begin(); it != tok.end(); ++it)
     {
+      // Check that we are not too many columns in.
+      if (col >= matrix.n_rows)
+      {
+        std::stringstream error;
+        error << "Too many columns in line " << (headerLines + row) << ".";
+        throw std::runtime_error(error.str());
+      }
+
       // What should this token be?
       if (info.Type(col) == Datatype::categorical)
       {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list