Author: luc
Date: Mon Oct 10 19:56:03 2011
New Revision: 1181181
URL: http://svn.apache.org/viewvc?rev=1181181&view=rev
Log:
Fixed an integer overflow in OpenMapRealMatrix.
JIRA: MATH-679
Added:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/OpenMapRealMatrixTest.java
(with props)
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
commons/proper/math/trunk/src/site/xdoc/changes.xml
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealMatrix.java?rev=1181181&r1=1181180&r2=1181181&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/OpenMapRealMatrix.java
Mon Oct 10 19:56:03 2011
@@ -19,6 +19,7 @@ package org.apache.commons.math.linear;
import java.io.Serializable;
+import org.apache.commons.math.exception.NumberIsTooLargeException;
import org.apache.commons.math.util.OpenIntToDoubleHashMap;
/**
@@ -46,6 +47,11 @@ public class OpenMapRealMatrix extends A
*/
public OpenMapRealMatrix(int rowDimension, int columnDimension) {
super(rowDimension, columnDimension);
+ long lRow = (long) rowDimension;
+ long lCol = (long) columnDimension;
+ if (lRow * lCol >= (long) Integer.MAX_VALUE) {
+ throw new NumberIsTooLargeException(lRow * lCol,
Integer.MAX_VALUE, false);
+ }
this.rows = rowDimension;
this.columns = columnDimension;
this.entries = new OpenIntToDoubleHashMap(0.0);
Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=1181181&r1=1181180&r2=1181181&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Mon Oct 10 19:56:03 2011
@@ -52,6 +52,9 @@ The <action> type attribute can be add,u
If the output is not quite correct, check for invisible trailing spaces!
-->
<release version="3.0" date="TBD" description="TBD">
+ <action dev="luc" type="fix" issue="MATH-679" due-to="Christopher
Berner">
+ Fixed an integer overflow in OpenMapRealMatrix.
+ </action>
<action dev="erans" type="fix" issue="MATH-688">
"FastMath": Use constant fields instead of recomputing them at method
call.
Added:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/OpenMapRealMatrixTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/OpenMapRealMatrixTest.java?rev=1181181&view=auto
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/OpenMapRealMatrixTest.java
(added)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/OpenMapRealMatrixTest.java
Mon Oct 10 19:56:03 2011
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.math.linear;
+
+import org.apache.commons.math.exception.NumberIsTooLargeException;
+import org.junit.Test;
+
+public final class OpenMapRealMatrixTest {
+
+ @Test(expected=NumberIsTooLargeException.class)
+ public void testMath679() {
+ new OpenMapRealMatrix(3, Integer.MAX_VALUE);
+ }
+
+}
\ No newline at end of file
Propchange:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/OpenMapRealMatrixTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
commons/proper/math/trunk/src/test/java/org/apache/commons/math/linear/OpenMapRealMatrixTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"