Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 111844 Details for
Bug 246290
Ray#length() can result in integer overflow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch
Ray_Patch (text/plain), 3.81 KB, created by
Alex Boyko
on 2008-09-05 13:54:18 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Alex Boyko
Created:
2008-09-05 13:54:18 EDT
Size:
3.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.draw2d.test >Index: src/org/eclipse/draw2d/test/Draw2dTestSuite.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/test/org.eclipse.draw2d.test/src/org/eclipse/draw2d/test/Draw2dTestSuite.java,v >retrieving revision 1.19 >diff -u -r1.19 Draw2dTestSuite.java >--- src/org/eclipse/draw2d/test/Draw2dTestSuite.java 8 Aug 2008 15:08:50 -0000 1.19 >+++ src/org/eclipse/draw2d/test/Draw2dTestSuite.java 5 Sep 2008 17:52:34 -0000 >@@ -49,6 +49,7 @@ > addTest(new TestSuite(FigureUtilitiesTest.class)); > addTest(new TestSuite(RectangleTest.class)); > // addTest(new TestSuite(ColorConstantTest.class)); >+ addTest(new TestSuite(RayTest.class)); > } > > } >Index: src/org/eclipse/draw2d/test/RayTest.java >=================================================================== >RCS file: src/org/eclipse/draw2d/test/RayTest.java >diff -N src/org/eclipse/draw2d/test/RayTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/draw2d/test/RayTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,48 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.draw2d.test; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.draw2d.geometry.Ray; >+ >+/** >+ * Ray's tests >+ * >+ * @author aboyko >+ * >+ */ >+public class RayTest extends TestCase { >+ >+ /** >+ * @see TestCase#setUp() >+ */ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ } >+ >+ /** >+ * @see TestCase#tearDown() >+ */ >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ } >+ >+ public void test_length() { >+ testLengthValues(3, 4, 5); >+ testLengthValues(0, Integer.MAX_VALUE, Integer.MAX_VALUE); >+ } >+ >+ private void testLengthValues(int x, int y, double expectedLength) { >+ Ray ray = new Ray(x, y); >+ assertEquals(expectedLength, ray.length(), 0); >+ } >+} >#P org.eclipse.draw2d >Index: src/org/eclipse/draw2d/geometry/Ray.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Ray.java,v >retrieving revision 1.10 >diff -u -r1.10 Ray.java >--- src/org/eclipse/draw2d/geometry/Ray.java 30 Mar 2005 21:27:45 -0000 1.10 >+++ src/org/eclipse/draw2d/geometry/Ray.java 5 Sep 2008 17:52:34 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -96,6 +96,16 @@ > } > > /** >+ * Calculates the dot product of this Ray with another. >+ * @param r the Ray used to perform the dot product >+ * @return The dot product as <code>long</code> to avoid possible integer overflow >+ * @since 3.4.1 >+ */ >+long dotProductL(Ray r) { >+ return (long) x * r.x + (long) y * r.y; >+} >+ >+/** > * @see java.lang.Object#equals(Object) > */ > public boolean equals(Object obj) { >@@ -160,7 +170,7 @@ > * @since 2.0 > */ > public double length() { >- return Math.sqrt(dotProduct(this)); >+ return Math.sqrt(dotProductL(this)); > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ahunter.eclipse
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 246290
:
111729
| 111844