OSDN Git Service

LAMatrix#new errornously allows matrix with dimension 0. Fixed.
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Mon, 16 Jan 2012 10:45:21 +0000 (10:45 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Mon, 16 Jan 2012 10:45:21 +0000 (10:45 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@173 a2be9bc6-48de-4e38-9406-05402d4bc13c

MolLib/Ruby_bind/ruby_types.c

index b214564..ef55a57 100644 (file)
@@ -1346,6 +1346,10 @@ s_LAMatrix_Initialize(int argc, VALUE *argv, VALUE self)
                int row, column;
                row = NUM2INT(rb_Integer(argv[0]));
                column = NUM2INT(rb_Integer(argv[1]));
+               if (column <= 0)
+                       rb_raise(rb_eMolbyError, "Bad column dimension (%d) for creating LAMatrix", column);
+               if (row <= 0)
+                       rb_raise(rb_eMolbyError, "Bad row dimension (%d) for creating LAMatrix", row);
                mp = DATA_PTR(self);
                if (mp != NULL && mp->column * mp->row >= column * row) {
                        mp->column = column;