octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #45963] sparse matrices with negative size


From: Kai Torben Ohlhus
Subject: [Octave-bug-tracker] [bug #45963] sparse matrices with negative size
Date: Tue, 15 Sep 2015 11:35:34 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36

Follow-up Comment #2, bug #45963 (project octave):

The erroneous behavior of comment #1 has it roots very deep inside 
liboctave/array/Spase.h . There is


SparseRep (octave_idx_type nr, octave_idx_type nc, octave_idx_type nz = 0)
  : d (nz > 0 ? new T [nz] : 0),
    r (nz > 0 ? new octave_idx_type [nz] : 0),
    c (new octave_idx_type [nc+1]), nzmx (nz), nrows (nr),
    ncols (nc), count (1)
{
  for (octave_idx_type i = 0; i < nc + 1; i++)
    c[i] = 0;
}


When you call


>> s = sparse(1e20,1)


nr = 1e20 and nc = 1 get directly forwarded from the interpreter only with a
check for nonnegativity!!! If you swapped the parameters, nc = 1e20 causes the
creation of a too large array and results in a bad_alloc exception.

To my opinion this is a problem that should be addressed in the dim_vector
class. It should be impossible to exceed the min and max index.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45963>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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