Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Guard long adding against overflows.

[#597][#598]

Signed-off-by: Mark Paluch <mpaluch@vmware.com>
  • Loading branch information
mp911de committed Jun 16, 2023
1 parent cb8b5ec commit 9b656c9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/io/r2dbc/postgresql/PostgresqlResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ public Mono<Long> getRowsUpdated() {
long sum = 0;

for (Long value : list) {
sum += value;
try {
sum = Math.addExact(sum, value);
} catch (ArithmeticException e) {
sum = Long.MAX_VALUE;
break;
}
}

sink.next(sum);
Expand Down

0 comments on commit 9b656c9

Please sign in to comment.