You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/08/21 09:24:03 UTC
[groovy] 03/11: Fix potential bugs when
Math.abs(Integer.MIN_VALUE)<0
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit fc4fa9aaa117160f457eb41286da5f07e0f80f07
Author: Bo Zhang <zh...@gmail.com>
AuthorDate: Sat Aug 17 19:10:28 2019 +0800
Fix potential bugs when Math.abs(Integer.MIN_VALUE)<0
It is possible for a call to hashCode to return Integer.MIN_VALUE.
Take the absolute value of such a hashcode and you'll still have a negative number.
To fix the problem, cast it to long.
---
src/main/java/groovy/lang/GroovyClassLoader.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/groovy/lang/GroovyClassLoader.java b/src/main/java/groovy/lang/GroovyClassLoader.java
index 262b232..2d726d9 100644
--- a/src/main/java/groovy/lang/GroovyClassLoader.java
+++ b/src/main/java/groovy/lang/GroovyClassLoader.java
@@ -270,7 +270,7 @@ public class GroovyClassLoader extends URLClassLoader {
*/
public Class parseClass(String text) throws CompilationFailedException {
return parseClass(text, "script" + System.currentTimeMillis() +
- Math.abs(text.hashCode()) + ".groovy");
+ Math.abs((long) text.hashCode()) + ".groovy");
}
public synchronized String generateScriptName() {