Browse Source

Merge pull request #1150 from akiyamaneko/list_util_enhanecd

修复ListUtil潜在的overflow异常
Golden Looly 5 years ago
parent
commit
a82d5b2905
1 changed files with 2 additions and 2 deletions
  1. 2 2
      hutool-core/src/main/java/cn/hutool/core/collection/ListUtil.java

+ 2 - 2
hutool-core/src/main/java/cn/hutool/core/collection/ListUtil.java

@@ -252,8 +252,8 @@ public class ListUtil {
 				return new ArrayList<>(0);
 			}
 		}
-
-		if ((pageNo * pageSize) > resultSize) {
+		// 相乘可能会导致越界 临时用long
+		if (((long)pageNo * pageSize) > resultSize) {
 			// 越界直接返回空
 			return new ArrayList<>(0);
 		}