From 88340e4e89e19695bdec48c64988377366934453 Mon Sep 17 00:00:00 2001 From: Louis Bergelson Date: Sun, 13 Apr 2025 12:53:36 -0400 Subject: [PATCH] Potential fix for code scanning alert no. 15: Implicit narrowing conversion in compound assignment Fixes a bug where sums were accidentally cast down to int. Looking at the usages it seems like it's unlikely it was ever a problem in practice because the sums calculated look like they would never have been bigger than max int. Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .../java/org/broadinstitute/hellbender/utils/MathUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/broadinstitute/hellbender/utils/MathUtils.java b/src/main/java/org/broadinstitute/hellbender/utils/MathUtils.java index 2a258033452..a105128222f 100644 --- a/src/main/java/org/broadinstitute/hellbender/utils/MathUtils.java +++ b/src/main/java/org/broadinstitute/hellbender/utils/MathUtils.java @@ -524,7 +524,7 @@ public static long sum(final int[] x) { public static long sum(final long[] x) { Utils.nonNull(x); - int total = 0; + long total = 0; for (long v : x) total += v; return total;