Skip to content

Commit a51504e

Browse files
committed
Polishing.
Guard long adding against overflows. [#597][#598] Signed-off-by: Mark Paluch <[email protected]>
1 parent 808589d commit a51504e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/io/r2dbc/postgresql/PostgresqlResult.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ public Mono<Long> getRowsUpdated() {
9292
long sum = 0;
9393

9494
for (Long value : list) {
95-
sum += value;
95+
try {
96+
sum = Math.addExact(sum, value);
97+
} catch (ArithmeticException e) {
98+
sum = Long.MAX_VALUE;
99+
break;
100+
}
96101
}
97102

98103
sink.next(sum);

0 commit comments

Comments
 (0)